diff --git a/Cargo.lock b/Cargo.lock index ca383e57cd..0a1aea7811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,6 +182,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "assert_approx_eq" version = "1.1.0" @@ -258,6 +264,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "autocfg" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -394,16 +409,28 @@ dependencies = [ "radium 0.3.0", ] +[[package]] +name = "bitvec" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +dependencies = [ + "funty 1.1.0", + "radium 0.6.2", + "tap", + "wyz 0.2.0", +] + [[package]] name = "bitvec" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ - "funty", + "funty 2.0.0", "radium 0.7.0", "tap", - "wyz", + "wyz 0.5.1", ] [[package]] @@ -490,7 +517,7 @@ dependencies = [ "parking_lot 0.11.2", "primitives", "rand 0.7.3", - "rlp", + "rlp 0.4.6", "secret-store", "toml", "txgen", @@ -724,6 +751,93 @@ dependencies = [ "ethcore-bytes", ] +[[package]] +name = "cfx-db-errors" +version = "2.0.2" +dependencies = [ + "cfx-types", + "error-chain", + "primitives", + "rlp 0.4.6", + "sqlite", + "strfmt", +] + +[[package]] +name = "cfx-execute-helper" +version = "2.0.2" +dependencies = [ + "cfx-bytes", + "cfx-executor", + "cfx-internal-common", + "cfx-parameters", + "cfx-statedb", + "cfx-types", + "cfx-vm-tracer-derive", + "cfx-vm-types", + "error-chain", + "log", + "malloc_size_of", + "malloc_size_of_derive", + "pow-types", + "primitives", + "rlp 0.4.6", + "rlp_derive", + "serde", + "serde_derive", + "solidity-abi", + "strum_macros 0.20.1", + "typemap", +] + +[[package]] +name = "cfx-executor" +version = "2.0.2" +dependencies = [ + "bls-signatures", + "byteorder", + "cfx-bytes", + "cfx-internal-common", + "cfx-math", + "cfx-parameters", + "cfx-statedb", + "cfx-storage", + "cfx-types", + "cfx-vm-interpreter", + "cfx-vm-tracer-derive", + "cfx-vm-types", + "cfxkey", + "diem-crypto", + "diem-types", + "error-chain", + "impl-tools", + "impl-trait-for-tuples 0.2.2", + "keccak-hash", + "lazy_static", + "log", + "malloc_size_of", + "malloc_size_of_derive", + "num", + "parity-crypto", + "parking_lot 0.11.2", + "pow-types", + "primitives", + "rlp 0.4.6", + "rlp_derive", + "rustc-hex", + "serde", + "serde_derive", + "serde_json", + "sha3-macro", + "solidity-abi", + "solidity-abi-derive", + "strum 0.20.0", + "strum_macros 0.20.1", + "substrate-bn", + "tiny-keccak 2.0.2", + "typemap", +] + [[package]] name = "cfx-internal-common" version = "1.0.0" @@ -738,7 +852,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot 0.11.2", "primitives", - "rlp", + "rlp 0.4.6", "rlp_derive", "serde", "serde_derive", @@ -780,30 +894,20 @@ dependencies = [ name = "cfx-parameters" version = "1.0.0" dependencies = [ + "cfx-bytes", "cfx-types", + "cfx-vm-types", + "cfxkey", "hex-literal", "lazy_static", -] - -[[package]] -name = "cfx-state" -version = "1.0.0" -dependencies = [ - "cfx-internal-common", - "cfx-parameters", - "cfx-statedb", - "cfx-storage", - "cfx-types", - "keccak-hash", - "parking_lot 0.11.2", - "primitives", - "rlp", + "rustc-hex", ] [[package]] name = "cfx-statedb" version = "1.0.0" dependencies = [ + "cfx-db-errors", "cfx-internal-common", "cfx-parameters", "cfx-storage", @@ -814,7 +918,7 @@ dependencies = [ "log", "parking_lot 0.11.2", "primitives", - "rlp", + "rlp 0.4.6", "tiny-keccak 2.0.2", ] @@ -824,6 +928,7 @@ version = "1.0.0" dependencies = [ "cfg-if 0.1.10", "cfx-bytes", + "cfx-db-errors", "cfx-internal-common", "cfx-types", "delegate 0.5.2", @@ -849,7 +954,7 @@ dependencies = [ "rand 0.7.3", "rand_chacha 0.2.2", "random-crash", - "rlp", + "rlp 0.4.6", "rlp_derive", "rustc-hex", "serde", @@ -880,7 +985,7 @@ name = "cfx-types" version = "0.2.0" dependencies = [ "ethereum-types 0.9.2", - "rlp", + "rlp 0.4.6", "rlp_derive", "serde", "serde_derive", @@ -894,9 +999,52 @@ dependencies = [ "parking_lot 0.11.2", ] +[[package]] +name = "cfx-vm-interpreter" +version = "2.0.2" +dependencies = [ + "bit-set 0.4.0", + "cfx-bytes", + "cfx-types", + "cfx-vm-types", + "keccak-hash", + "lazy_static", + "log", + "malloc_size_of", + "memory-cache", + "parking_lot 0.11.2", + "rustc-hex", +] + +[[package]] +name = "cfx-vm-tracer-derive" +version = "0.1.0" +dependencies = [ + "proc-macro2 1.0.71", + "quote 1.0.33", + "syn 1.0.109", +] + +[[package]] +name = "cfx-vm-types" +version = "2.0.2" +dependencies = [ + "bls-signatures", + "cfx-bytes", + "cfx-db-errors", + "cfx-types", + "keccak-hash", + "primitives", + "rlp 0.4.6", + "rlp_derive", + "serde", + "serde_derive", + "solidity-abi", +] + [[package]] name = "cfxcore" -version = "2.3.4" +version = "2.3.5" dependencies = [ "anyhow", "async-oneshot", @@ -909,15 +1057,19 @@ dependencies = [ "cached-pos-ledger-db", "cfx-addr", "cfx-bytes", + "cfx-execute-helper", + "cfx-executor", "cfx-internal-common", "cfx-math", "cfx-packing-pool", "cfx-parameters", - "cfx-state", "cfx-statedb", "cfx-storage", "cfx-types", "cfx-utils", + "cfx-vm-interpreter", + "cfx-vm-tracer-derive", + "cfx-vm-types", "cfxkey", "channel", "clap", @@ -947,6 +1099,8 @@ dependencies = [ "hashbrown 0.7.2", "heap-map", "hibitset", + "impl-tools", + "impl-trait-for-tuples 0.2.2", "io", "itertools 0.9.0", "jsonrpc-core", @@ -987,7 +1141,7 @@ dependencies = [ "rand_xorshift 0.2.0", "random-crash", "rayon", - "rlp", + "rlp 0.4.6", "rlp_derive", "rustc-hex", "safety-rules", @@ -1046,11 +1200,14 @@ name = "cfxkey" version = "0.3.0" dependencies = [ "cfx-types", + "docopt", "edit-distance", + "env_logger", "lazy_static", "log", "malloc_size_of", "malloc_size_of_derive", + "panic_hook", "parity-crypto", "parity-secp256k1", "parity-wordlist", @@ -1059,6 +1216,7 @@ dependencies = [ "rustc-hex", "serde", "serde_derive", + "threadpool", "tiny-keccak 1.5.0", "zeroize", ] @@ -1087,6 +1245,23 @@ dependencies = [ "tiny-keccak 1.5.0", ] +[[package]] +name = "cfxstore-cli" +version = "0.1.1" +dependencies = [ + "cfxstore", + "dir", + "docopt", + "env_logger", + "num_cpus", + "panic_hook", + "parking_lot 0.11.2", + "rustc-hex", + "serde", + "serde_derive", + "tempdir", +] + [[package]] name = "channel" version = "0.1.0" @@ -1167,7 +1342,7 @@ dependencies = [ [[package]] name = "client" -version = "2.3.4" +version = "2.3.5" dependencies = [ "anyhow", "app_dirs", @@ -1177,12 +1352,14 @@ dependencies = [ "cached-pos-ledger-db", "cfx-addr", "cfx-bytes", + "cfx-execute-helper", + "cfx-executor", "cfx-internal-common", "cfx-parameters", - "cfx-state", "cfx-statedb", "cfx-storage", "cfx-types", + "cfx-vm-types", "cfxcore", "cfxcore-accounts", "cfxkey", @@ -1240,7 +1417,7 @@ dependencies = [ "rand_xorshift 0.2.0", "random-crash", "rayon", - "rlp", + "rlp 0.4.6", "rpassword 5.0.1", "runtime", "rustc-hex", @@ -1297,7 +1474,7 @@ dependencies = [ [[package]] name = "conflux" -version = "2.3.4" +version = "2.3.5" dependencies = [ "app_dirs", "base64ct", @@ -1344,7 +1521,7 @@ dependencies = [ "pos-ledger-db", "primitives", "rand 0.8.5", - "rlp", + "rlp 0.4.6", "rpassword 4.0.5", "runtime", "rustc-hex", @@ -1533,7 +1710,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg", + "autocfg 1.1.0", "cfg-if 0.1.10", "crossbeam-utils 0.7.2", "lazy_static", @@ -1548,7 +1725,7 @@ version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ - "autocfg", + "autocfg 1.1.0", "cfg-if 1.0.0", "crossbeam-utils 0.8.15", "memoffset 0.8.0", @@ -1582,7 +1759,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg", + "autocfg 1.1.0", "cfg-if 0.1.10", "lazy_static", ] @@ -1672,6 +1849,21 @@ dependencies = [ "winapi 0.2.8", ] +[[package]] +name = "ctxkey-cli" +version = "0.1.0" +dependencies = [ + "cfxkey", + "docopt", + "env_logger", + "panic_hook", + "parity-wordlist", + "rustc-hex", + "serde", + "serde_derive", + "threadpool", +] + [[package]] name = "curve25519-dalek-fiat" version = "0.1.0" @@ -2355,7 +2547,7 @@ checksum = "32cfe1c169414b709cf28aa30c74060bdb830a03a8ba473314d079ac79d80a5f" dependencies = [ "crunchy", "fixed-hash 0.5.2", - "impl-rlp", + "impl-rlp 0.2.1", "impl-serde 0.2.3", "tiny-keccak 1.5.0", ] @@ -2368,7 +2560,20 @@ checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" dependencies = [ "crunchy", "fixed-hash 0.6.1", - "impl-rlp", + "impl-rlp 0.2.1", + "impl-serde 0.3.2", + "tiny-keccak 2.0.2", +] + +[[package]] +name = "ethbloom" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" +dependencies = [ + "crunchy", + "fixed-hash 0.7.0", + "impl-rlp 0.3.0", "impl-serde 0.3.2", "tiny-keccak 2.0.2", ] @@ -2387,10 +2592,10 @@ checksum = "ba744248e3553a393143d5ebb68939fc3a4ec0c22a269682535f5ffe7fed728c" dependencies = [ "ethbloom 0.8.1", "fixed-hash 0.5.2", - "impl-rlp", + "impl-rlp 0.2.1", "impl-serde 0.2.3", "primitive-types 0.6.2", - "uint", + "uint 0.8.5", ] [[package]] @@ -2401,10 +2606,24 @@ checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" dependencies = [ "ethbloom 0.9.2", "fixed-hash 0.6.1", - "impl-rlp", + "impl-rlp 0.2.1", "impl-serde 0.3.2", "primitive-types 0.7.3", - "uint", + "uint 0.8.5", +] + +[[package]] +name = "ethereum-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05136f7057fe789f06e6d41d07b34e6f70d8c86e5693b60f97aaa6553553bdaf" +dependencies = [ + "ethbloom 0.11.1", + "fixed-hash 0.7.0", + "impl-rlp 0.3.0", + "impl-serde 0.3.2", + "primitive-types 0.10.1", + "uint 0.9.5", ] [[package]] @@ -2558,6 +2777,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "fixed-hash" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + [[package]] name = "fixedbitset" version = "0.2.0" @@ -2644,6 +2875,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + [[package]] name = "funty" version = "2.0.0" @@ -2972,7 +3209,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" dependencies = [ "ahash", - "autocfg", + "autocfg 1.1.0", ] [[package]] @@ -3340,7 +3577,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" dependencies = [ - "parity-scale-codec", + "parity-scale-codec 1.3.7", +] + +[[package]] +name = "impl-codec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "161ebdfec3c8e3b52bf61c4f3550a1eea4f9579d10dc1b936f3171ebdcd6c443" +dependencies = [ + "parity-scale-codec 2.3.1", ] [[package]] @@ -3349,7 +3595,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" dependencies = [ - "rlp", + "rlp 0.4.6", +] + +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp 0.5.2", ] [[package]] @@ -3370,6 +3625,30 @@ dependencies = [ "serde", ] +[[package]] +name = "impl-tools" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82c305b1081f1a99fda262883c788e50ab57d36c00830bdd7e0a82894ad965c" +dependencies = [ + "autocfg 1.1.0", + "impl-tools-lib", + "proc-macro-error", + "syn 2.0.42", +] + +[[package]] +name = "impl-tools-lib" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85d3946d886eaab0702fa0c6585adcced581513223fa9df7ccfabbd9fa331a88" +dependencies = [ + "proc-macro-error", + "proc-macro2 1.0.71", + "quote 1.0.33", + "syn 2.0.42", +] + [[package]] name = "impl-trait-for-tuples" version = "0.1.3" @@ -3381,13 +3660,24 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2 1.0.71", + "quote 1.0.33", + "syn 1.0.109", +] + [[package]] name = "indexmap" version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ - "autocfg", + "autocfg 1.1.0", "hashbrown 0.12.3", ] @@ -3883,7 +4173,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ - "autocfg", + "autocfg 1.1.0", "scopeguard 1.1.0", ] @@ -3897,6 +4187,19 @@ dependencies = [ "serde", ] +[[package]] +name = "log-device" +version = "0.1.0" +dependencies = [ + "byteorder", + "db", + "kvdb", + "parking_lot 0.11.2", + "rand 0.7.3", + "rlp 0.4.6", + "rlp_derive", +] + [[package]] name = "log-mdc" version = "0.1.0" @@ -4017,7 +4320,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" dependencies = [ - "autocfg", + "autocfg 1.1.0", ] [[package]] @@ -4026,7 +4329,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ - "autocfg", + "autocfg 1.1.0", ] [[package]] @@ -4256,7 +4559,7 @@ dependencies = [ "parking_lot 0.11.2", "priority-send-queue", "rand 0.7.3", - "rlp", + "rlp 0.4.6", "rlp_derive", "serde", "serde_derive", @@ -4306,7 +4609,7 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -4317,7 +4620,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-traits", ] @@ -4338,7 +4641,7 @@ version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-traits", ] @@ -4348,7 +4651,7 @@ version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-integer", "num-traits", ] @@ -4359,7 +4662,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "autocfg", + "autocfg 1.1.0", "num-bigint", "num-integer", "num-traits", @@ -4371,7 +4674,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ - "autocfg", + "autocfg 1.1.0", "libm", ] @@ -4475,7 +4778,7 @@ version = "0.9.82" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a95792af3c4e0153c3914df2261bedd30a98476f94dc892b67dfe1d89d433a04" dependencies = [ - "autocfg", + "autocfg 1.1.0", "cc", "libc", "pkg-config", @@ -4530,10 +4833,14 @@ dependencies = [ "aes-ctr", "block-modes 0.7.0", "digest 0.9.0", + "ethereum-types 0.12.1", "hmac 0.10.1", + "lazy_static", "pbkdf2 0.7.5", "ripemd160", + "rustc-hex", "scrypt 0.5.0", + "secp256k1", "sha2 0.9.9", "subtle", "tiny-keccak 2.0.2", @@ -4555,19 +4862,45 @@ version = "1.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4b26b16c7687c3075982af47719e481815df30bc544f7a6690763a25ca16e9d" dependencies = [ - "arrayvec", + "arrayvec 0.5.2", "bitvec 0.17.4", "byte-slice-cast 0.3.5", "serde", ] +[[package]] +name = "parity-scale-codec" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" +dependencies = [ + "arrayvec 0.7.4", + "bitvec 0.20.4", + "byte-slice-cast 1.2.2", + "impl-trait-for-tuples 0.2.2", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2 1.0.71", + "quote 1.0.33", + "syn 1.0.109", +] + [[package]] name = "parity-secp256k1" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fca4f82fccae37e8bbdaeb949a4a218a1bbc485d11598f193d2a908042e5fc1" dependencies = [ - "arrayvec", + "arrayvec 0.5.2", "cc", "cfg-if 0.1.10", "rand 0.7.3", @@ -4580,7 +4913,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9344bc978467339b9ae688f9dcf279d1aaa0ccfc88e9a780c729b765a82d57d5" dependencies = [ "cfg-if 0.1.10", - "impl-trait-for-tuples", + "impl-trait-for-tuples 0.1.3", "parity-util-mem-derive", "winapi 0.3.9", ] @@ -5064,10 +5397,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4336f4f5d5524fa60bcbd6fe626f9223d8142a50e7053e979acdf0da41ab975" dependencies = [ "fixed-hash 0.5.2", - "impl-codec", - "impl-rlp", + "impl-codec 0.4.2", + "impl-rlp 0.2.1", "impl-serde 0.3.2", - "uint", + "uint 0.8.5", ] [[package]] @@ -5077,10 +5410,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" dependencies = [ "fixed-hash 0.6.1", - "impl-codec", - "impl-rlp", + "impl-codec 0.4.2", + "impl-rlp 0.2.1", + "impl-serde 0.3.2", + "uint 0.8.5", +] + +[[package]] +name = "primitive-types" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" +dependencies = [ + "fixed-hash 0.7.0", + "impl-codec 0.5.1", + "impl-rlp 0.3.0", "impl-serde 0.3.2", - "uint", + "uint 0.9.5", ] [[package]] @@ -5099,7 +5445,7 @@ dependencies = [ "malloc_size_of", "once_cell", "rand 0.7.3", - "rlp", + "rlp 0.4.6", "rlp_derive", "serde", "serde_derive", @@ -5284,6 +5630,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" +[[package]] +name = "radium" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" + [[package]] name = "radium" version = "0.7.0" @@ -5303,6 +5655,25 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.8", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift 0.1.1", + "winapi 0.3.9", +] + [[package]] name = "rand" version = "0.7.3" @@ -5313,7 +5684,7 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc", + "rand_hc 0.2.0", ] [[package]] @@ -5327,6 +5698,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.3.1", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -5380,6 +5761,15 @@ dependencies = [ "getrandom 0.2.8", ] +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -5389,6 +5779,59 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.9", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.9", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + [[package]] name = "rand_xorshift" version = "0.2.0" @@ -5589,6 +6032,16 @@ dependencies = [ "rustc-hex", ] +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes 1.4.0", + "rustc-hex", +] + [[package]] name = "rlp_derive" version = "0.1.0" @@ -5849,6 +6302,25 @@ dependencies = [ "sha2 0.10.6", ] +[[package]] +name = "secp256k1" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d03ceae636d0fed5bae6a7f4f664354c5f4fcedf6eef053fef17e49f837d0a" +dependencies = [ + "rand 0.6.5", + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +dependencies = [ + "cc", +] + [[package]] name = "secret-store" version = "0.1.0" @@ -5859,7 +6331,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot 0.11.2", "rand 0.7.3", - "rlp", + "rlp 0.4.6", ] [[package]] @@ -6135,7 +6607,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ - "autocfg", + "autocfg 1.1.0", ] [[package]] @@ -6678,7 +7150,7 @@ version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ - "autocfg", + "autocfg 1.1.0", "bytes 1.4.0", "libc", "memchr", @@ -6992,6 +7464,12 @@ dependencies = [ "once_cell", ] +[[package]] +name = "traitobject" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" + [[package]] name = "transient-hashmap" version = "0.4.1" @@ -7039,6 +7517,7 @@ version = "0.1.0" dependencies = [ "cfx-bytes", "cfx-types", + "cfx-vm-types", "cfxcore", "cfxkey", "clap", @@ -7052,12 +7531,21 @@ dependencies = [ "primitives", "priority-send-queue", "rand 0.7.3", - "rlp", + "rlp 0.4.6", "rustc-hex", "secret-store", "toml", ] +[[package]] +name = "typemap" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" +dependencies = [ + "unsafe-any", +] + [[package]] name = "typemap-ors" version = "1.0.0" @@ -7085,6 +7573,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex 0.4.3", + "static_assertions", +] + [[package]] name = "unarray" version = "0.1.4" @@ -7170,6 +7670,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "unsafe-any" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" +dependencies = [ + "traitobject", +] + [[package]] name = "unsafe-any-ors" version = "1.0.0" @@ -7560,6 +8069,12 @@ dependencies = [ "winapi-build", ] +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index fad4b2fdbc..caf9b6a747 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,102 +1,69 @@ -[package] -name = "conflux" -version = "2.3.4" -edition = "2018" -build = "build.rs" - -[dependencies] -mio = "0.6.8" -clap = { version = "2", features = ["yaml"] } -textwrap = "0.9" -toml = "0.5.8" -serde = "1.0" -serde_json = "1.0" -serde_derive = "1.0" -parking_lot = "0.11" -panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } -app_dirs = "1.2.1" -dir = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } -cfxstore = { path = "accounts/cfxstore" } -cfxcore-accounts = { path = "accounts" } -home = "0.5.0" -rpassword = "4.0.1" -io = { path = "util/io" } -runtime = { path = "util/runtime" } -ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git", rev="b523017108bb2d571a7a69bd97bc406e63bc7a9d" } -jsonrpc-core = "15.1.0" -jsonrpc-tcp-server = "15.1.0" -jsonrpc-http-server = "15.1.0" -jsonrpc-core-client = { version = "15.1.0", features = ["http"] } -error-chain = { version = "0.12" } -log = "0.4" -slab = "0.4" -cfxcore = { path = "core" } -network = { path = "network" } -db = { path = "db" } -blockgen = { path = "blockgen" } -txgen = { path = "transactiongen" } -secret-store = { path = "secret_store" } -primitives = { path = "primitives" } -log4rs = { version = "1.2.0", features = ["background_rotation", "gzip"] } -rlp = "0.4.0" -keccak-hash = "0.5" -rand = "0.8.3" -kvdb-rocksdb = {path="db/src/kvdb-rocksdb"} -client = { path = "client" } -cfx-types = { path = "cfx_types" } -threadpool = "1.7" -futures = "0.1.29" -docopt = "1.0" -cfxkey = { path = "accounts/cfxkey" } -parity-wordlist = "1.3.0" -rustc-hex = "2.1" -env_logger = "0.5" -malloc_size_of = {path="util/malloc_size_of"} -diem-crypto = { path="core/src/pos/crypto/crypto" } -diem-types = { path="core/src/pos/types" } -pos-ledger-db = { path = "core/src/pos/storage/pos-ledger-db" } -executor-types = { path = "core/src/pos/types/executor-types" } -executor = { path = "core/src/pos/consensus/executor" } -storage-interface = { path = "core/src/pos/storage/storage-interface" } -move-core-types = { path = "core/src/pos/types/move-core-types"} -bcs = "0.1.3" -tempdir = "0.3.7" -hex = "0.3.0" -base64ct = "=1.1.1" -parity-version = {path = "./util/version"} - -[target.'cfg(not(target_env = "msvc"))'.dependencies.jemallocator] -version = "0.3.2" -optional = true - -[[bin]] -name = "consensus_bench" -path = "core/benchmark/consensus/src/main.rs" - -[[bin]] -name = "cfx-gen-dot" -path = "tools/cfx-gen-dot/main.rs" - -[[bin]] -name = "cfxkey" -path = "accounts/cfxkey/cli/src/main.rs" - -[[bin]] -name = "pos-genesis-tool" -path = "tools/pos-genesis-tool/main.rs" - # Use workspace section to allow test all cases under root folder (cargo test --all). [workspace] +members = [ + "crates/cfx_bytes", + "crates/cfx_types", + "crates/cfx_addr", + "crates/cfx_math", + "crates/cfx_utils", + "crates/stratum", + "crates/accounts", + "crates/blockgen", + "crates/cfx_key", + "crates/cfx_store", + "crates/dbs/db", + "crates/dbs/kvdb-rocksdb", + "crates/dbs/db-errors", + "crates/network", + "crates/primitives", + "crates/secret_store", + "crates/transactiongen", + "bins/cfx_store", + "bins/cfx_key", + "bins/conflux", + "crates/cfxcore/core", + "crates/cfxcore/execute-helper", + "crates/cfxcore/executor", + "crates/cfxcore/internal_common", + "crates/cfxcore/packing-pool", + "crates/cfxcore/parameters", + "crates/dbs/statedb", + "crates/dbs/storage", + "crates/cfxcore/vm-interpreter", + "crates/cfxcore/vm-types", + "crates/util/cfx-vm-tracer-derive", + "crates/util/dag", + "crates/util/delegate", + "crates/util/heap-map", + "crates/util/hibitset", + "crates/util/io", + "crates/util/link-cut-tree", + "crates/util/log_device", + "crates/util/malloc_size_of", + "crates/util/malloc_size_of_derive", + "crates/util/memory-cache", + "crates/util/metrics", + "crates/util/priority-send-queue", + "crates/util/random_crash", + "crates/util/runtime", + "crates/util/sha3-macro", + "crates/util/solidity-abi", + "crates/util/solidity-abi-derive", + "crates/util/throttling", + "crates/util/treap-map", + "crates/util/version" +] -[features] -default = ["jemalloc-global", "bls-blst"] -deadlock-detection = ["parking_lot/deadlock_detection"] -jemalloc-global = ["jemallocator", "malloc_size_of/jemalloc-global"] -bls-blst = ["cfxcore/bls-blst", "diem-crypto/bls-blst"] -bls-pairing = ["cfxcore/bls-pairing", "diem-crypto/bls-pairing"] -blst-portable = ["cfxcore/blst-portable", "diem-crypto/blst-portable"] -u64-mpt-db-key = ["client/u64_mpt_db_key"] - +[workspace.package] +version = "2.3.5" +authors = ["peilun-conflux", "ChenxingLi"] +description = "A rust implementation of the Conflux-Protocol" +documentation = "https://doc.confluxnetwork.org" +#edition = "2018" +homepage = "https://confluxnetwork.org/" +keywords = ["Conflux"] +repository = "https://github.com/conflux-chain/conflux-rust" +license-file = "LICENSE" [patch.crates-io] sqlite3-sys = { git = "https://github.com/Conflux-Chain/sqlite3-sys.git", rev = "1de8e5998f7c2d919336660b8ef4e8f52ac43844" } @@ -114,4 +81,4 @@ overflow-checks = true [profile.release] overflow-checks = true # Temporarily run with debug assertion before main-net release. -debug-assertions = true +debug-assertions = true \ No newline at end of file diff --git a/README.md b/README.md index 82cd4d18b2..947ae3f5a8 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,22 @@ # Conflux-Rust Conflux-rust is a Rust-based implementation of the Conflux protocol. It is fast and -reliable. Please follow the [Conflux +reliable. + +## For Users + +Please follow the [Conflux Documentation](https://doc.confluxnetwork.org/) to [build](https://doc.confluxnetwork.org/docs/general/run-a-node/advanced-topics/compiling-conflux-client) and [run](https://doc.confluxnetwork.org/docs/general/run-a-node/) Conflux. -## Contribution +## For Developers + +For a general overview of the crates, see [Project Layout](./docs/repo/layout.md). + +### Contribution Thank you for considering helping out with our source code. We appreciate any contributions, even the smallest fixes. Please read the @@ -17,7 +25,7 @@ on how to submit issues and pull requests. Note that if you want to propose significant changes to the Conflux protocol, please submit a [CIP](https://github.com/Conflux-Chain/CIPs). -## Unit Tests and Integration Tests +### Unit Tests and Integration Tests Unit tests come together with the Rust code. They can be invoked via `cargo test --release --all`. See the [Getting Started](https://doc.confluxnetwork.org/docs/general/run-a-node/) diff --git a/accounts/cfxstore/cli/src/crack.rs b/accounts/cfxstore/cli/src/crack.rs deleted file mode 100644 index c037508b51..0000000000 --- a/accounts/cfxstore/cli/src/crack.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2019-2020 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -// 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::{cmp, thread}; -use std::sync::Arc; -use std::collections::VecDeque; -use parking_lot::Mutex; - -use cfxstore::{cfxkey::Password, PresaleWallet, Error}; -use num_cpus; - -pub fn run(passwords: VecDeque, wallet_path: &str) -> Result<(), Error> { - let passwords = Arc::new(Mutex::new(passwords)); - - let mut handles = Vec::new(); - - for _ in 0..num_cpus::get() { - let passwords = passwords.clone(); - let wallet = PresaleWallet::open(&wallet_path)?; - handles.push(thread::spawn(move || { - look_for_password(passwords, wallet); - })); - } - - for handle in handles { - handle.join().map_err(|err| Error::Custom(format!("Error finishing thread: {:?}", err)))?; - } - - Ok(()) -} - -fn look_for_password(passwords: Arc>>, wallet: PresaleWallet) { - let mut counter = 0; - while !passwords.lock().is_empty() { - let package = { - let mut passwords = passwords.lock(); - let len = passwords.len(); - passwords.split_off(cmp::min(len, 32)) - }; - for pass in package { - counter += 1; - match wallet.decrypt(&pass) { - Ok(_) => { - println!("Found password: {}", pass.as_str()); - passwords.lock().clear(); - return; - }, - _ if counter % 100 == 0 => print!("."), - _ => {}, - } - } - } -} diff --git a/accounts/cfxstore/cli/src/main.rs b/accounts/cfxstore/cli/src/main.rs deleted file mode 100644 index f711b74ec3..0000000000 --- a/accounts/cfxstore/cli/src/main.rs +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright 2019-2020 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -// 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 . - -extern crate dir; -extern crate docopt; -extern crate cfxstore; -extern crate num_cpus; -extern crate panic_hook; -extern crate parking_lot; -extern crate rustc_hex; -extern crate serde; - -extern crate env_logger; - -#[macro_use] -extern crate serde_derive; - -use std::collections::VecDeque; -use std::io::Read; -use std::{env, process, fs, fmt}; - -use docopt::Docopt; -use cfxstore::accounts_dir::{KeyDirectory, RootDiskDirectory}; -use cfxstore::cfxkey::{Address, Password}; -use cfxstore::{EthStore, SimpleSecretStore, SecretStore, import_accounts, PresaleWallet, SecretVaultRef, StoreAccountRef}; - -mod crack; - -pub const USAGE: &'static str = r#" -Conflux key management tool. - -Usage: - cfxstore insert [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore change-pwd
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore list [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore import [] [--src DIR] [--dir DIR] - cfxstore import-wallet [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore find-wallet-pass - cfxstore remove
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore sign
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore public
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore list-vaults [--dir DIR] - cfxstore create-vault [--dir DIR] - cfxstore change-vault-pwd [--dir DIR] - cfxstore move-to-vault
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] - cfxstore move-from-vault
[--dir DIR] - cfxstore [-h | --help] - -Options: - -h, --help Display this message and exit. - --dir DIR Specify the secret store directory. It may be either - parity, parity-(chain), geth, geth-test - or a path [default: parity]. - --vault VAULT Specify vault to use in this operation. - --vault-pwd VAULTPWD Specify vault password to use in this operation. Please note - that this option is required when vault option is set. - Otherwise it is ignored. - --src DIR Specify import source. It may be either - parity, parity-(chain), geth, geth-test - or a path [default: geth]. - -Commands: - insert Save account with password. - change-pwd Change password. - list List accounts. - import Import accounts from src. - import-wallet Import presale wallet. - find-wallet-pass Tries to open a wallet with list of passwords given. - remove Remove account. - sign Sign message. - public Displays public key for an address. - list-vaults List vaults. - create-vault Create new vault. - change-vault-pwd Change vault password. - move-to-vault Move account to vault from another vault/root directory. - move-from-vault Move account to root directory from given vault. -"#; - -#[derive(Debug, Deserialize)] -struct Args { - cmd_insert: bool, - cmd_change_pwd: bool, - cmd_list: bool, - cmd_import: bool, - cmd_import_wallet: bool, - cmd_find_wallet_pass: bool, - cmd_remove: bool, - cmd_sign: bool, - cmd_public: bool, - cmd_list_vaults: bool, - cmd_create_vault: bool, - cmd_change_vault_pwd: bool, - cmd_move_to_vault: bool, - cmd_move_from_vault: bool, - arg_secret: String, - arg_password: String, - arg_old_pwd: String, - arg_new_pwd: String, - arg_address: String, - arg_message: String, - arg_path: String, - arg_vault: String, - flag_src: String, - flag_dir: String, - flag_vault: String, - flag_vault_pwd: String, -} - -enum Error { - Ethstore(cfxstore::Error), - Docopt(docopt::Error), -} - -impl From for Error { - fn from(err: cfxstore::Error) -> Self { - Error::Ethstore(err) - } -} - -impl From for Error { - fn from(err: docopt::Error) -> Self { - Error::Docopt(err) - } -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - Error::Ethstore(ref err) => fmt::Display::fmt(err, f), - Error::Docopt(ref err) => fmt::Display::fmt(err, f), - } - } -} - -fn main() { - panic_hook::set_abort(); - if env::var("RUST_LOG").is_err() { - env::set_var("RUST_LOG", "warn") - } - env_logger::try_init().expect("Logger initialized only once."); - - match execute(env::args()) { - Ok(result) => println!("{}", result), - Err(Error::Docopt(ref e)) => e.exit(), - Err(err) => { - eprintln!("{}", err); - process::exit(1); - } - } -} - -fn key_dir(location: &str, password: Option) -> Result, Error> { - let dir: RootDiskDirectory = match location { - "geth" => RootDiskDirectory::create(dir::geth(false))?, - "geth-test" => RootDiskDirectory::create(dir::geth(true))?, - path if path.starts_with("parity") => { - let chain = path.split('-').nth(1).unwrap_or("ethereum"); - let path = dir::parity(chain); - RootDiskDirectory::create(path)? - }, - path => RootDiskDirectory::create(path)?, - }; - - Ok(Box::new(dir.with_password(password))) -} - -fn open_args_vault(store: &EthStore, args: &Args) -> Result { - if args.flag_vault.is_empty() { - return Ok(SecretVaultRef::Root); - } - - let vault_pwd = load_password(&args.flag_vault_pwd)?; - store.open_vault(&args.flag_vault, &vault_pwd)?; - Ok(SecretVaultRef::Vault(args.flag_vault.clone())) -} - -fn open_args_vault_account(store: &EthStore, address: Address, args: &Args) -> Result { - match open_args_vault(store, args)? { - SecretVaultRef::Root => Ok(StoreAccountRef::root(address)), - SecretVaultRef::Vault(name) => Ok(StoreAccountRef::vault(&name, address)), - } -} - -fn format_accounts(accounts: &[Address]) -> String { - accounts.iter() - .enumerate() - .map(|(i, a)| format!("{:2}: 0x{:x}", i, a)) - .collect::>() - .join("\n") -} - -fn format_vaults(vaults: &[String]) -> String { - vaults.join("\n") -} - -fn load_password(path: &str) -> Result { - let mut file = fs::File::open(path).map_err(|e| cfxstore::Error::Custom(format!("Error opening password file '{}': {}", path, e)))?; - let mut password = String::new(); - file.read_to_string(&mut password).map_err(|e| cfxstore::Error::Custom(format!("Error reading password file '{}': {}", path, e)))?; - // drop EOF - let _ = password.pop(); - Ok(password.into()) -} - -fn execute(command: I) -> Result where I: IntoIterator, S: AsRef { - let args: Args = Docopt::new(USAGE) - .and_then(|d| d.argv(command).deserialize())?; - - let store = EthStore::open(key_dir(&args.flag_dir, None)?)?; - - return if args.cmd_insert { - let secret = args.arg_secret.parse().map_err(|_| cfxstore::Error::InvalidSecret)?; - let password = load_password(&args.arg_password)?; - let vault_ref = open_args_vault(&store, &args)?; - let account_ref = store.insert_account(vault_ref, secret, &password)?; - Ok(format!("0x{:x}", account_ref.address)) - } else if args.cmd_change_pwd { - let address = args.arg_address.parse().map_err(|_| cfxstore::Error::InvalidAccount)?; - let old_pwd = load_password(&args.arg_old_pwd)?; - let new_pwd = load_password(&args.arg_new_pwd)?; - let account_ref = open_args_vault_account(&store, address, &args)?; - let ok = store.change_password(&account_ref, &old_pwd, &new_pwd).is_ok(); - Ok(format!("{}", ok)) - } else if args.cmd_list { - let vault_ref = open_args_vault(&store, &args)?; - let accounts = store.accounts()?; - let accounts: Vec<_> = accounts - .into_iter() - .filter(|a| &a.vault == &vault_ref) - .map(|a| a.address) - .collect(); - Ok(format_accounts(&accounts)) - } else if args.cmd_import { - let password = match args.arg_password.as_ref() { - "" => None, - _ => Some(load_password(&args.arg_password)?) - }; - let src = key_dir(&args.flag_src, password)?; - let dst = key_dir(&args.flag_dir, None)?; - - let accounts = import_accounts(&*src, &*dst)?; - Ok(format_accounts(&accounts)) - } else if args.cmd_import_wallet { - let wallet = PresaleWallet::open(&args.arg_path)?; - let password = load_password(&args.arg_password)?; - let kp = wallet.decrypt(&password)?; - let vault_ref = open_args_vault(&store, &args)?; - let account_ref = store.insert_account(vault_ref, kp.secret().clone(), &password)?; - Ok(format!("0x{:x}", account_ref.address)) - } else if args.cmd_find_wallet_pass { - let passwords = load_password(&args.arg_password)?; - let passwords = passwords.as_str().lines().map(|line| str::to_owned(line).into()).collect::>(); - crack::run(passwords, &args.arg_path)?; - Ok(format!("Password not found.")) - } else if args.cmd_remove { - let address = args.arg_address.parse().map_err(|_| cfxstore::Error::InvalidAccount)?; - let password = load_password(&args.arg_password)?; - let account_ref = open_args_vault_account(&store, address, &args)?; - let ok = store.remove_account(&account_ref, &password).is_ok(); - Ok(format!("{}", ok)) - } else if args.cmd_sign { - let address = args.arg_address.parse().map_err(|_| cfxstore::Error::InvalidAccount)?; - let message = args.arg_message.parse().map_err(|_| cfxstore::Error::InvalidMessage)?; - let password = load_password(&args.arg_password)?; - let account_ref = open_args_vault_account(&store, address, &args)?; - let signature = store.sign(&account_ref, &password, &message)?; - Ok(format!("0x{}", signature)) - } else if args.cmd_public { - let address = args.arg_address.parse().map_err(|_| cfxstore::Error::InvalidAccount)?; - let password = load_password(&args.arg_password)?; - let account_ref = open_args_vault_account(&store, address, &args)?; - let public = store.public(&account_ref, &password)?; - Ok(format!("0x{:x}", public)) - } else if args.cmd_list_vaults { - let vaults = store.list_vaults()?; - Ok(format_vaults(&vaults)) - } else if args.cmd_create_vault { - let password = load_password(&args.arg_password)?; - store.create_vault(&args.arg_vault, &password)?; - Ok("OK".to_owned()) - } else if args.cmd_change_vault_pwd { - let old_pwd = load_password(&args.arg_old_pwd)?; - let new_pwd = load_password(&args.arg_new_pwd)?; - store.open_vault(&args.arg_vault, &old_pwd)?; - store.change_vault_password(&args.arg_vault, &new_pwd)?; - Ok("OK".to_owned()) - } else if args.cmd_move_to_vault { - let address = args.arg_address.parse().map_err(|_| cfxstore::Error::InvalidAccount)?; - let password = load_password(&args.arg_password)?; - let account_ref = open_args_vault_account(&store, address, &args)?; - store.open_vault(&args.arg_vault, &password)?; - store.change_account_vault(SecretVaultRef::Vault(args.arg_vault), account_ref)?; - Ok("OK".to_owned()) - } else if args.cmd_move_from_vault { - let address = args.arg_address.parse().map_err(|_| cfxstore::Error::InvalidAccount)?; - let password = load_password(&args.arg_password)?; - store.open_vault(&args.arg_vault, &password)?; - store.change_account_vault(SecretVaultRef::Root, StoreAccountRef::vault(&args.arg_vault, address))?; - Ok("OK".to_owned()) - } else { - Ok(format!("{}", USAGE)) - } -} diff --git a/accounts/cfxstore/cli/tests/cli.rs b/accounts/cfxstore/cli/tests/cli.rs deleted file mode 100644 index 39e40864f2..0000000000 --- a/accounts/cfxstore/cli/tests/cli.rs +++ /dev/null @@ -1,82 +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 . - -extern crate tempdir; -use std::process::Command; -use tempdir::TempDir; -use std::fs::File; -use std::io::Write; - -fn run(args: &[&str]) -> String { - let output = Command::new("cargo") - .args(&["run", "--"]) - .args(args) - .output() - .unwrap(); - assert!(output.status.success()); - String::from_utf8(output.stdout).unwrap() -} - -#[test] -fn cli_cmd() { - Command::new("cargo") - .arg("build") - .output() - .unwrap(); - - let dir = TempDir::new("test-vault").unwrap(); - - let mut passwd = File::create(dir.path().join("test-password")).unwrap(); - writeln!(passwd, "password").unwrap(); - - let mut passwd2 = File::create(dir.path().join("test-vault-addr")).unwrap(); - writeln!(passwd2, "password2").unwrap(); - - let test_password_buf = dir.path().join("test-password"); - let test_password: &str = test_password_buf.to_str().unwrap(); - let dir_str: &str = dir.path().to_str().unwrap(); - let test_vault_addr_buf = dir.path().join("test-vault-addr"); - let test_vault_addr = test_vault_addr_buf.to_str().unwrap(); - - run(&["create-vault", "test-vault", test_password, "--dir", dir_str]); - - let output = run(&["insert", "7d29fab185a33e2cd955812397354c472d2b84615b645aa135ff539f6b0d70d5", - test_vault_addr, - "--dir", dir_str, - "--vault", "test-vault", - "--vault-pwd", test_password]); - let address = output.trim(); - - let output = run(&["list", - "--dir", dir_str, - "--vault", "test-vault", - "--vault-pwd", test_password]); - assert_eq!(output, " 0: 0xa8fa5dd30a87bb9e3288d604eb74949c515ab66e\n"); - - let output = run(&["sign", &address[2..], - test_vault_addr, - "7d29fab185a33e2cd955812397354c472d2b84615b645aa135ff539f6b0d70d5", - "--dir", dir_str, - "--vault", "test-vault", - "--vault-pwd", test_password]); - assert_eq!(output, "0x54ab6e5cf0c5cb40043fdca5d15d611a3a94285414a076dafecc8dc9c04183f413296a3defff61092c0bb478dc9887ec01070e1275234211208fb8f4be4a9b0101\n"); - - let output = run(&["public", &address[2..], test_vault_addr, - "--dir", dir_str, - "--vault", "test-vault", - "--vault-pwd", test_password]); - assert_eq!(output, "0x35f222d88b80151857a2877826d940104887376a94c1cbd2c8c7c192eb701df88a18a4ecb8b05b1466c5b3706042027b5e079fe3a3683e66d822b0e047aa3418\n"); -} diff --git a/tools/cfx-gen-dot/main.rs b/bins/cfx-gen-dot/main.rs similarity index 100% rename from tools/cfx-gen-dot/main.rs rename to bins/cfx-gen-dot/main.rs diff --git a/accounts/cfxkey/cli/Cargo.toml b/bins/cfx_key/Cargo.toml similarity index 89% rename from accounts/cfxkey/cli/Cargo.toml rename to bins/cfx_key/Cargo.toml index 5cbc3007b1..42e5d9d740 100644 --- a/accounts/cfxkey/cli/Cargo.toml +++ b/bins/cfx_key/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] [dependencies] docopt = "1.0" env_logger = "0.5" -cfxkey = { path = "../" } +cfxkey = { path = "../../crates/cfx_key" } panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } parity-wordlist="1.2" rustc-hex = "2.1" @@ -18,4 +18,4 @@ threadpool = "1.7" [[bin]] name = "cfxkey" path = "src/main.rs" -doc = false +doc = false \ No newline at end of file diff --git a/accounts/cfxkey/cli/src/main.rs b/bins/cfx_key/src/main.rs similarity index 97% rename from accounts/cfxkey/cli/src/main.rs rename to bins/cfx_key/src/main.rs index e8b3ba0604..96993f73ec 100644 --- a/accounts/cfxkey/cli/src/main.rs +++ b/bins/cfx_key/src/main.rs @@ -387,7 +387,7 @@ mod tests { .collect::>(); let expected = -"secret: 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55 + "secret: 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55 public: 689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124 address: 16d1ec50b4e62c1d1a40d16e7cacc6a6580757d5".to_owned(); assert_eq!(execute(command).unwrap(), expected); @@ -401,7 +401,7 @@ address: 16d1ec50b4e62c1d1a40d16e7cacc6a6580757d5".to_owned(); .collect::>(); let expected = -"The recover phrase was not generated by Conflux: The word 'this' does not come from the dictionary. + "The recover phrase was not generated by Conflux: The word 'this' does not come from the dictionary. secret: a6bb621db2721ee05c44de651dde50ef85feefc5e91ae23bedcae69b874a22e7 public: 756cb3f7ad1516b7c0ee34bd5e8b3a519922d3737192a58115e47df57ff3270873360a61de523ce08c0ebd7d3801bcb1d03c0364431d2b8633067f3d79e1fb25 @@ -466,9 +466,9 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned(); #[test] fn verify_valid_public() { let command = vec!["cfxkey", "verify", "public", "689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987"] - .into_iter() - .map(Into::into) - .collect::>(); + .into_iter() + .map(Into::into) + .collect::>(); let expected = "true".to_owned(); assert_eq!(execute(command).unwrap(), expected); @@ -477,9 +477,9 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned(); #[test] fn verify_valid_address() { let command = vec!["cfxkey", "verify", "address", "16d1ec50b4e62c1d1a40d16e7cacc6a6580757d5", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec987"] - .into_iter() - .map(Into::into) - .collect::>(); + .into_iter() + .map(Into::into) + .collect::>(); let expected = "true".to_owned(); assert_eq!(execute(command).unwrap(), expected); @@ -488,9 +488,9 @@ address: 10a33d9f95b22fe53024331c036db6e824a25bab".to_owned(); #[test] fn verify_invalid() { let command = vec!["cfxkey", "verify", "public", "689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124", "c1878cf60417151c766a712653d26ef350c8c75393458b7a9be715f053215af63dfd3b02c2ae65a8677917a8efa3172acb71cb90196e42106953ea0363c5aaf200", "bd50b7370c3f96733b31744c6c45079e7ae6c8d299613246d28ebcef507ec986"] - .into_iter() - .map(Into::into) - .collect::>(); + .into_iter() + .map(Into::into) + .collect::>(); let expected = "false".to_owned(); assert_eq!(execute(command).unwrap(), expected); diff --git a/accounts/cfxstore/cli/Cargo.toml b/bins/cfx_store/Cargo.toml similarity index 93% rename from accounts/cfxstore/cli/Cargo.toml rename to bins/cfx_store/Cargo.toml index c0279d66be..10e4e9dcf0 100644 --- a/accounts/cfxstore/cli/Cargo.toml +++ b/bins/cfx_store/Cargo.toml @@ -12,7 +12,7 @@ rustc-hex = "2.1" serde = "1.0" serde_derive = "1.0" parking_lot = "0.11" -cfxstore = { path = "../" } +cfxstore = { path = "../../crates/cfx_store" } panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } dir = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } diff --git a/bins/cfx_store/src/crack.rs b/bins/cfx_store/src/crack.rs new file mode 100644 index 0000000000..699a5a6c75 --- /dev/null +++ b/bins/cfx_store/src/crack.rs @@ -0,0 +1,74 @@ +// Copyright 2019-2020 Conflux Foundation. All rights reserved. +// Conflux is free software and distributed under GNU General Public License. +// See http://www.gnu.org/licenses/ + +// 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 parking_lot::Mutex; +use std::{cmp, collections::VecDeque, sync::Arc, thread}; + +use cfxstore::{cfxkey::Password, Error, PresaleWallet}; +use num_cpus; + +pub fn run( + passwords: VecDeque, wallet_path: &str, +) -> Result<(), Error> { + let passwords = Arc::new(Mutex::new(passwords)); + + let mut handles = Vec::new(); + + for _ in 0..num_cpus::get() { + let passwords = passwords.clone(); + let wallet = PresaleWallet::open(&wallet_path)?; + handles.push(thread::spawn(move || { + look_for_password(passwords, wallet); + })); + } + + for handle in handles { + handle.join().map_err(|err| { + Error::Custom(format!("Error finishing thread: {:?}", err)) + })?; + } + + Ok(()) +} + +fn look_for_password( + passwords: Arc>>, wallet: PresaleWallet, +) { + let mut counter = 0; + while !passwords.lock().is_empty() { + let package = { + let mut passwords = passwords.lock(); + let len = passwords.len(); + passwords.split_off(cmp::min(len, 32)) + }; + for pass in package { + counter += 1; + match wallet.decrypt(&pass) { + Ok(_) => { + println!("Found password: {}", pass.as_str()); + passwords.lock().clear(); + return; + } + _ if counter % 100 == 0 => print!("."), + _ => {} + } + } + } +} diff --git a/bins/cfx_store/src/main.rs b/bins/cfx_store/src/main.rs new file mode 100644 index 0000000000..470b25b6c1 --- /dev/null +++ b/bins/cfx_store/src/main.rs @@ -0,0 +1,375 @@ +// Copyright 2019-2020 Conflux Foundation. All rights reserved. +// Conflux is free software and distributed under GNU General Public License. +// See http://www.gnu.org/licenses/ + +// 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 . + +extern crate cfxstore; +extern crate dir; +extern crate docopt; +extern crate num_cpus; +extern crate panic_hook; +extern crate parking_lot; +extern crate rustc_hex; +extern crate serde; + +extern crate env_logger; + +#[macro_use] +extern crate serde_derive; + +use std::{collections::VecDeque, env, fmt, fs, io::Read, process}; + +use cfxstore::{ + accounts_dir::{KeyDirectory, RootDiskDirectory}, + cfxkey::{Address, Password, Secret}, + import_accounts, CfxStore, PresaleWallet, SecretStore, SecretVaultRef, + SimpleSecretStore, StoreAccountRef, +}; +use docopt::Docopt; + +mod crack; + +pub const USAGE: &'static str = r#" +Conflux key management tool. + +Usage: + cfxstore insert [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore change-pwd
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore list [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore import [] [--src DIR] [--dir DIR] + cfxstore import-wallet [--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore find-wallet-pass + cfxstore remove
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore sign
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore public
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore list-vaults [--dir DIR] + cfxstore create-vault [--dir DIR] + cfxstore change-vault-pwd [--dir DIR] + cfxstore move-to-vault
[--dir DIR] [--vault VAULT] [--vault-pwd VAULTPWD] + cfxstore move-from-vault
[--dir DIR] + cfxstore [-h | --help] + +Options: + -h, --help Display this message and exit. + --dir DIR Specify the secret store directory. It may be either + parity, parity-(chain), geth, geth-test + or a path [default: parity]. + --vault VAULT Specify vault to use in this operation. + --vault-pwd VAULTPWD Specify vault password to use in this operation. Please note + that this option is required when vault option is set. + Otherwise it is ignored. + --src DIR Specify import source. It may be either + parity, parity-(chain), geth, geth-test + or a path [default: geth]. + +Commands: + insert Save account with password. + change-pwd Change password. + list List accounts. + import Import accounts from src. + import-wallet Import presale wallet. + find-wallet-pass Tries to open a wallet with list of passwords given. + remove Remove account. + sign Sign message. + public Displays public key for an address. + list-vaults List vaults. + create-vault Create new vault. + change-vault-pwd Change vault password. + move-to-vault Move account to vault from another vault/root directory. + move-from-vault Move account to root directory from given vault. +"#; + +#[derive(Debug, Deserialize)] +struct Args { + cmd_insert: bool, + cmd_change_pwd: bool, + cmd_list: bool, + cmd_import: bool, + cmd_import_wallet: bool, + cmd_find_wallet_pass: bool, + cmd_remove: bool, + cmd_sign: bool, + cmd_public: bool, + cmd_list_vaults: bool, + cmd_create_vault: bool, + cmd_change_vault_pwd: bool, + cmd_move_to_vault: bool, + cmd_move_from_vault: bool, + arg_secret: String, + arg_password: String, + arg_old_pwd: String, + arg_new_pwd: String, + arg_address: String, + arg_message: String, + arg_path: String, + arg_vault: String, + flag_src: String, + flag_dir: String, + flag_vault: String, + flag_vault_pwd: String, +} + +enum Error { + Ethstore(cfxstore::Error), + Docopt(docopt::Error), +} + +impl From for Error { + fn from(err: cfxstore::Error) -> Self { Error::Ethstore(err) } +} + +impl From for Error { + fn from(err: docopt::Error) -> Self { Error::Docopt(err) } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Error::Ethstore(ref err) => fmt::Display::fmt(err, f), + Error::Docopt(ref err) => fmt::Display::fmt(err, f), + } + } +} + +fn main() { + panic_hook::set_abort(); + if env::var("RUST_LOG").is_err() { + env::set_var("RUST_LOG", "warn") + } + env_logger::try_init().expect("Logger initialized only once."); + + match execute(env::args()) { + Ok(result) => println!("{}", result), + Err(Error::Docopt(ref e)) => e.exit(), + Err(err) => { + eprintln!("{}", err); + process::exit(1); + } + } +} + +fn key_dir( + location: &str, password: Option, +) -> Result, Error> { + let dir: RootDiskDirectory = match location { + "geth" => RootDiskDirectory::create(dir::geth(false))?, + "geth-test" => RootDiskDirectory::create(dir::geth(true))?, + path if path.starts_with("parity") => { + let chain = path.split('-').nth(1).unwrap_or("ethereum"); + let path = dir::parity(chain); + RootDiskDirectory::create(path)? + } + path => RootDiskDirectory::create(path)?, + }; + + Ok(Box::new(dir.with_password(password))) +} + +fn open_args_vault( + store: &CfxStore, args: &Args, +) -> Result { + if args.flag_vault.is_empty() { + return Ok(SecretVaultRef::Root); + } + + let vault_pwd = load_password(&args.flag_vault_pwd)?; + store.open_vault(&args.flag_vault, &vault_pwd)?; + Ok(SecretVaultRef::Vault(args.flag_vault.clone())) +} + +fn open_args_vault_account( + store: &CfxStore, address: Address, args: &Args, +) -> Result { + match open_args_vault(store, args)? { + SecretVaultRef::Root => Ok(StoreAccountRef::root(address)), + SecretVaultRef::Vault(name) => { + Ok(StoreAccountRef::vault(&name, address)) + } + } +} + +fn format_accounts(accounts: &[Address]) -> String { + accounts + .iter() + .enumerate() + .map(|(i, a)| format!("{:2}: 0x{:x}", i, a)) + .collect::>() + .join("\n") +} + +fn format_vaults(vaults: &[String]) -> String { vaults.join("\n") } + +fn load_password(path: &str) -> Result { + let mut file = fs::File::open(path).map_err(|e| { + cfxstore::Error::Custom(format!( + "Error opening password file '{}': {}", + path, e + )) + })?; + let mut password = String::new(); + file.read_to_string(&mut password).map_err(|e| { + cfxstore::Error::Custom(format!( + "Error reading password file '{}': {}", + path, e + )) + })?; + // drop EOF + let _ = password.pop(); + Ok(password.into()) +} + +fn execute(command: I) -> Result +where + I: IntoIterator, + S: AsRef, +{ + let args: Args = + Docopt::new(USAGE).and_then(|d| d.argv(command).deserialize())?; + + let store = CfxStore::open(key_dir(&args.flag_dir, None)?)?; + + return if args.cmd_insert { + let secret = args + .arg_secret + .parse() + .map_err(|_| cfxstore::Error::InvalidSecret)?; + let password = load_password(&args.arg_password)?; + let vault_ref = open_args_vault(&store, &args)?; + let account_ref = store.insert_account(vault_ref, secret, &password)?; + Ok(format!("0x{:x}", account_ref.address)) + } else if args.cmd_change_pwd { + let address = args + .arg_address + .parse() + .map_err(|_| cfxstore::Error::InvalidAccount)?; + let old_pwd = load_password(&args.arg_old_pwd)?; + let new_pwd = load_password(&args.arg_new_pwd)?; + let account_ref = open_args_vault_account(&store, address, &args)?; + let ok = store + .change_password(&account_ref, &old_pwd, &new_pwd) + .is_ok(); + Ok(format!("{}", ok)) + } else if args.cmd_list { + let vault_ref = open_args_vault(&store, &args)?; + let accounts = store.accounts()?; + let accounts: Vec<_> = accounts + .into_iter() + .filter(|a| &a.vault == &vault_ref) + .map(|a| a.address) + .collect(); + Ok(format_accounts(&accounts)) + } else if args.cmd_import { + let password = match args.arg_password.as_ref() { + "" => None, + _ => Some(load_password(&args.arg_password)?), + }; + let src = key_dir(&args.flag_src, password)?; + let dst = key_dir(&args.flag_dir, None)?; + + let accounts = import_accounts(&*src, &*dst)?; + Ok(format_accounts(&accounts)) + } else if args.cmd_import_wallet { + let wallet = PresaleWallet::open(&args.arg_path)?; + let password = load_password(&args.arg_password)?; + let kp = wallet.decrypt(&password)?; + let vault_ref = open_args_vault(&store, &args)?; + let secret = Secret::from(kp.secret().to_fixed_bytes()); + let account_ref = store.insert_account(vault_ref, secret, &password)?; + Ok(format!("0x{:x}", account_ref.address)) + } else if args.cmd_find_wallet_pass { + let passwords = load_password(&args.arg_password)?; + let passwords = passwords + .as_str() + .lines() + .map(|line| str::to_owned(line).into()) + .collect::>(); + crack::run(passwords, &args.arg_path)?; + Ok(format!("Password not found.")) + } else if args.cmd_remove { + let address = args + .arg_address + .parse() + .map_err(|_| cfxstore::Error::InvalidAccount)?; + let password = load_password(&args.arg_password)?; + let account_ref = open_args_vault_account(&store, address, &args)?; + let ok = store.remove_account(&account_ref, &password).is_ok(); + Ok(format!("{}", ok)) + } else if args.cmd_sign { + let address = args + .arg_address + .parse() + .map_err(|_| cfxstore::Error::InvalidAccount)?; + let message = args + .arg_message + .parse() + .map_err(|_| cfxstore::Error::InvalidMessage)?; + let password = load_password(&args.arg_password)?; + let account_ref = open_args_vault_account(&store, address, &args)?; + let signature = store.sign(&account_ref, &password, &message)?; + Ok(format!("0x{}", signature)) + } else if args.cmd_public { + let address = args + .arg_address + .parse() + .map_err(|_| cfxstore::Error::InvalidAccount)?; + let password = load_password(&args.arg_password)?; + let account_ref = open_args_vault_account(&store, address, &args)?; + let public = store.public(&account_ref, &password)?; + Ok(format!("0x{:x}", public)) + } else if args.cmd_list_vaults { + let vaults = store.list_vaults()?; + Ok(format_vaults(&vaults)) + } else if args.cmd_create_vault { + let password = load_password(&args.arg_password)?; + store.create_vault(&args.arg_vault, &password)?; + Ok("OK".to_owned()) + } else if args.cmd_change_vault_pwd { + let old_pwd = load_password(&args.arg_old_pwd)?; + let new_pwd = load_password(&args.arg_new_pwd)?; + store.open_vault(&args.arg_vault, &old_pwd)?; + store.change_vault_password(&args.arg_vault, &new_pwd)?; + Ok("OK".to_owned()) + } else if args.cmd_move_to_vault { + let address = args + .arg_address + .parse() + .map_err(|_| cfxstore::Error::InvalidAccount)?; + let password = load_password(&args.arg_password)?; + let account_ref = open_args_vault_account(&store, address, &args)?; + store.open_vault(&args.arg_vault, &password)?; + store.change_account_vault( + SecretVaultRef::Vault(args.arg_vault), + account_ref, + )?; + Ok("OK".to_owned()) + } else if args.cmd_move_from_vault { + let address = args + .arg_address + .parse() + .map_err(|_| cfxstore::Error::InvalidAccount)?; + let password = load_password(&args.arg_password)?; + store.open_vault(&args.arg_vault, &password)?; + store.change_account_vault( + SecretVaultRef::Root, + StoreAccountRef::vault(&args.arg_vault, address), + )?; + Ok("OK".to_owned()) + } else { + Ok(format!("{}", USAGE)) + }; +} diff --git a/bins/cfx_store/tests/cli.rs b/bins/cfx_store/tests/cli.rs new file mode 100644 index 0000000000..212ccd9819 --- /dev/null +++ b/bins/cfx_store/tests/cli.rs @@ -0,0 +1,107 @@ +// 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 . + +extern crate tempdir; +use std::{fs::File, io::Write, process::Command}; +use tempdir::TempDir; + +fn run(args: &[&str]) -> String { + let output = Command::new("cargo") + .args(&["run", "--"]) + .args(args) + .output() + .unwrap(); + assert!(output.status.success()); + String::from_utf8(output.stdout).unwrap() +} + +#[test] +fn cli_cmd() { + Command::new("cargo").arg("build").output().unwrap(); + + let dir = TempDir::new("test-vault").unwrap(); + + let mut passwd = File::create(dir.path().join("test-password")).unwrap(); + writeln!(passwd, "password").unwrap(); + + let mut passwd2 = File::create(dir.path().join("test-vault-addr")).unwrap(); + writeln!(passwd2, "password2").unwrap(); + + let test_password_buf = dir.path().join("test-password"); + let test_password: &str = test_password_buf.to_str().unwrap(); + let dir_str: &str = dir.path().to_str().unwrap(); + let test_vault_addr_buf = dir.path().join("test-vault-addr"); + let test_vault_addr = test_vault_addr_buf.to_str().unwrap(); + + run(&[ + "create-vault", + "test-vault", + test_password, + "--dir", + dir_str, + ]); + + let output = run(&[ + "insert", + "7d29fab185a33e2cd955812397354c472d2b84615b645aa135ff539f6b0d70d5", + test_vault_addr, + "--dir", + dir_str, + "--vault", + "test-vault", + "--vault-pwd", + test_password, + ]); + let address = output.trim(); + + let output = run(&[ + "list", + "--dir", + dir_str, + "--vault", + "test-vault", + "--vault-pwd", + test_password, + ]); + assert_eq!(output, " 0: 0x18fa5dd30a87bb9e3288d604eb74949c515ab66e\n"); + + let output = run(&[ + "sign", + &address[2..], + test_vault_addr, + "7d29fab185a33e2cd955812397354c472d2b84615b645aa135ff539f6b0d70d5", + "--dir", + dir_str, + "--vault", + "test-vault", + "--vault-pwd", + test_password, + ]); + assert_eq!(output, "0x54ab6e5cf0c5cb40043fdca5d15d611a3a94285414a076dafecc8dc9c04183f413296a3defff61092c0bb478dc9887ec01070e1275234211208fb8f4be4a9b0101\n"); + + let output = run(&[ + "public", + &address[2..], + test_vault_addr, + "--dir", + dir_str, + "--vault", + "test-vault", + "--vault-pwd", + test_password, + ]); + assert_eq!(output, "0x35f222d88b80151857a2877826d940104887376a94c1cbd2c8c7c192eb701df88a18a4ecb8b05b1466c5b3706042027b5e079fe3a3683e66d822b0e047aa3418\n"); +} diff --git a/bins/conflux/Cargo.toml b/bins/conflux/Cargo.toml new file mode 100644 index 0000000000..ce3ba6da1d --- /dev/null +++ b/bins/conflux/Cargo.toml @@ -0,0 +1,94 @@ +[package] +name = "conflux" +build = "build.rs" +edition = "2018" +version.workspace = true +authors.workspace = true +description.workspace = true +documentation.workspace = true + +[dependencies] +mio = "0.6.8" +clap = { version = "2", features = ["yaml"] } +textwrap = "0.9" +toml = "0.5.8" +serde = "1.0" +serde_json = "1.0" +serde_derive = "1.0" +parking_lot = "0.11" +panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } +app_dirs = "1.2.1" +dir = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } +cfxstore = { path = "../../crates/cfx_store" } +cfxcore-accounts = { path = "../../crates/accounts" } +home = "0.5.0" +rpassword = "4.0.1" +io = { path = "../../crates/util/io" } +runtime = { path = "../../crates/util/runtime" } +ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git", rev="b523017108bb2d571a7a69bd97bc406e63bc7a9d" } +jsonrpc-core = "15.1.0" +jsonrpc-tcp-server = "15.1.0" +jsonrpc-http-server = "15.1.0" +jsonrpc-core-client = { version = "15.1.0", features = ["http"] } +error-chain = { version = "0.12" } +log = "0.4" +slab = "0.4" +cfxcore = { path = "../../crates/cfxcore/core" } +network = { path = "../../crates/network" } +db = { path = "../../crates/dbs/db" } +blockgen = { path = "../../crates/blockgen" } +txgen = { path = "../../crates/transactiongen" } +secret-store = { path = "../../crates/secret_store" } +primitives = { path = "../../crates/primitives" } +log4rs = { version = "1.2.0", features = ["background_rotation", "gzip"] } +rlp = "0.4.0" +keccak-hash = "0.5" +rand = "0.8.3" +kvdb-rocksdb = {path= "../../crates/dbs/kvdb-rocksdb" } +client = { path = "../../crates/client" } +cfx-types = { path = "../../crates/cfx_types" } +threadpool = "1.7" +futures = "0.1.29" +docopt = "1.0" +cfxkey = { path = "../../crates/cfx_key" } +parity-wordlist = "1.3.0" +rustc-hex = "2.1" +env_logger = "0.5" +malloc_size_of = {path= "../../crates/util/malloc_size_of" } +diem-crypto = { path= "../../crates/cfxcore/core/src/pos/crypto/crypto" } +diem-types = { path= "../../crates/cfxcore/core/src/pos/types" } +pos-ledger-db = { path = "../../crates/cfxcore/core/src/pos/storage/pos-ledger-db" } +executor-types = { path = "../../crates/cfxcore/core/src/pos/types/executor-types" } +executor = { path = "../../crates/cfxcore/core/src/pos/consensus/executor" } +storage-interface = { path = "../../crates/cfxcore/core/src/pos/storage/storage-interface" } +move-core-types = { path = "../../crates/cfxcore/core/src/pos/types/move-core-types" } +bcs = "0.1.3" +tempdir = "0.3.7" +hex = "0.3.0" +base64ct = "=1.1.1" +parity-version = {path = "../../crates/util/version" } + +[target.'cfg(not(target_env = "msvc"))'.dependencies.jemallocator] +version = "0.3.2" +optional = true + +[[bin]] +name = "consensus_bench" +path = "../../crates/cfxcore/core/benchmark/consensus/src/main.rs" + +[[bin]] +name = "cfx-gen-dot" +path = "../cfx-gen-dot/main.rs" + +[[bin]] +name = "pos-genesis-tool" +path = "../pos-genesis-tool/main.rs" + +[features] +default = ["jemalloc-global", "bls-blst"] +deadlock-detection = ["parking_lot/deadlock_detection"] +jemalloc-global = ["jemallocator", "malloc_size_of/jemalloc-global"] +bls-blst = ["cfxcore/bls-blst", "diem-crypto/bls-blst"] +bls-pairing = ["cfxcore/bls-pairing", "diem-crypto/bls-pairing"] +blst-portable = ["cfxcore/blst-portable", "diem-crypto/blst-portable"] +u64-mpt-db-key = ["client/u64_mpt_db_key"] diff --git a/build.rs b/bins/conflux/build.rs similarity index 100% rename from build.rs rename to bins/conflux/build.rs diff --git a/src/cli.yaml b/bins/conflux/src/cli.yaml similarity index 100% rename from src/cli.yaml rename to bins/conflux/src/cli.yaml diff --git a/src/command/account.rs b/bins/conflux/src/command/account.rs similarity index 100% rename from src/command/account.rs rename to bins/conflux/src/command/account.rs diff --git a/src/command/helpers.rs b/bins/conflux/src/command/helpers.rs similarity index 100% rename from src/command/helpers.rs rename to bins/conflux/src/command/helpers.rs diff --git a/src/command/mod.rs b/bins/conflux/src/command/mod.rs similarity index 100% rename from src/command/mod.rs rename to bins/conflux/src/command/mod.rs diff --git a/src/command/rpc.rs b/bins/conflux/src/command/rpc.rs similarity index 100% rename from src/command/rpc.rs rename to bins/conflux/src/command/rpc.rs diff --git a/src/main.rs b/bins/conflux/src/main.rs similarity index 100% rename from src/main.rs rename to bins/conflux/src/main.rs diff --git a/src/test.rs b/bins/conflux/src/test.rs similarity index 100% rename from src/test.rs rename to bins/conflux/src/test.rs diff --git a/tools/pos-genesis-tool/main.rs b/bins/pos-genesis-tool/main.rs similarity index 98% rename from tools/pos-genesis-tool/main.rs rename to bins/pos-genesis-tool/main.rs index 6851074d03..2bf5c83094 100644 --- a/tools/pos-genesis-tool/main.rs +++ b/bins/pos-genesis-tool/main.rs @@ -29,7 +29,7 @@ use tempdir::TempDir; use cfx_types::H256; use cfxcore::{ consensus::pos_handler::save_initial_nodes_to_file, - spec::genesis::{ + genesis_block::{ register_transaction, GenesisPosNodeInfo, GenesisPosState, }, }; @@ -54,7 +54,7 @@ use diem_types::{ waypoint::Waypoint, write_set::WriteSet, }; -use executor::{db_bootstrapper::generate_waypoint, vm::FakeVM}; +use executor::{db_bootstrapper::generate_waypoint, vm::PosVM}; use pos_ledger_db::PosLedgerDB; use std::{ collections::{BTreeMap, BinaryHeap, HashMap}, @@ -162,7 +162,7 @@ fn execute_genesis_transaction(genesis_txn: Transaction) -> Waypoint { ) .expect("DB should open."), ); - generate_waypoint::(&db, &genesis_txn).unwrap() + generate_waypoint::(&db, &genesis_txn).unwrap() } fn generate_genesis_from_public_keys(public_keys: Vec<(NodeID, u64)>) { diff --git a/cargo_fmt.sh b/cargo_fmt.sh index 5a38e79d5b..b8b5de1c6c 100755 --- a/cargo_fmt.sh +++ b/cargo_fmt.sh @@ -2,9 +2,9 @@ set -e if [[ "$1" == "--install" ]] then - rustup toolchain add nightly-2019-07-03 - rustup component add rustfmt --toolchain nightly-2019-07-03 + rustup toolchain add nightly-2024-02-04 + rustup component add rustfmt --toolchain nightly-2024-02-04 rustup component add clippy shift fi -cargo +nightly-2019-07-03 fmt --all $@ +cargo +nightly-2024-02-04 fmt --all $@ diff --git a/core/benchmark/storage/Cargo.lock b/core/benchmark/storage/Cargo.lock deleted file mode 100644 index d7434dd70b..0000000000 --- a/core/benchmark/storage/Cargo.lock +++ /dev/null @@ -1,9738 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ab_glyph" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1061f3ff92c2f65800df1f12fc7b4ff44ee14783104187dd04dfee6f11b0fd2" -dependencies = [ - "ab_glyph_rasterizer", - "owned_ttf_parser", -] - -[[package]] -name = "ab_glyph_rasterizer" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" - -[[package]] -name = "accesskit" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eb1adf08c5bcaa8490b9851fd53cca27fa9880076f178ea9d29f05196728a8" - -[[package]] -name = "accesskit_consumer" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04bb4d9e4772fe0d47df57d0d5dbe5d85dd05e2f37ae1ddb6b105e76be58fb00" -dependencies = [ - "accesskit", -] - -[[package]] -name = "accesskit_macos" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d0acf6acb667c89d3332999b1a5df4edbc8d6113910f392ebb73f2b03bb56" -dependencies = [ - "accesskit", - "accesskit_consumer", - "objc2", - "once_cell", -] - -[[package]] -name = "accesskit_windows" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eac0a7f2d7cd7a93b938af401d3d8e8b7094217989a7c25c55a953023436e31" -dependencies = [ - "accesskit", - "accesskit_consumer", - "arrayvec 0.7.4", - "once_cell", - "paste", - "windows 0.48.0", -] - -[[package]] -name = "accesskit_winit" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "825d23acee1bd6d25cbaa3ca6ed6e73faf24122a774ec33d52c5c86c6ab423c0" -dependencies = [ - "accesskit", - "accesskit_macos", - "accesskit_windows", - "winit", -] - -[[package]] -name = "accumulator" -version = "0.1.0" -dependencies = [ - "anyhow", - "diem-crypto", - "diem-types", - "mirai-annotations", -] - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if 1.0.0", - "cipher 0.3.0", - "cpufeatures", - "opaque-debug", -] - -[[package]] -name = "aes-ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", - "ctr", -] - -[[package]] -name = "aes-gcm" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" -dependencies = [ - "aead", - "aes 0.6.0", - "cipher 0.2.5", - "ctr", - "ghash", - "subtle", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug", -] - -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" - -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if 1.0.0", - "getrandom 0.2.10", - "once_cell", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "allocator-api2" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" - -[[package]] -name = "alsa" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2562ad8dcf0f789f65c6fdaad8a8a9708ed6b488e649da28c01656ad66b8b47" -dependencies = [ - "alsa-sys", - "bitflags 1.3.2", - "libc", - "nix 0.24.3", -] - -[[package]] -name = "alsa-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" -dependencies = [ - "libc", - "pkg-config", -] - -[[package]] -name = "android-activity" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64529721f27c2314ced0890ce45e469574a73e5e6fdd6e9da1860eb29285f5e0" -dependencies = [ - "android-properties", - "bitflags 1.3.2", - "cc", - "jni-sys", - "libc", - "log", - "ndk", - "ndk-context", - "ndk-sys", - "num_enum 0.6.1", -] - -[[package]] -name = "android-properties" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" - -[[package]] -name = "android_log-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "ansi_term" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455" - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "approx" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" -dependencies = [ - "num-traits", -] - -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" - -[[package]] -name = "array-macro" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e97b4e522f9e55523001238ac59d13a8603af57f69980de5d8de4bbbe8ada6" - -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "ash" -version = "0.37.3+1.3.251" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" -dependencies = [ - "libloading 0.7.4", -] - -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-executor" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" -dependencies = [ - "async-lock", - "async-task", - "concurrent-queue", - "fastrand 2.0.1", - "futures-lite", - "slab", -] - -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-oneshot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec7c75bcbcb0139e9177f30692fd617405ca4e0c27802e128d53171f7042e2c" -dependencies = [ - "futures-micro", -] - -[[package]] -name = "async-task" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" - -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "atom" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9ff149ed9780025acfdb36862d35b28856bb693ceb451259a7164442f22fdc3" - -[[package]] -name = "attohttpc" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf13118df3e3dce4b5ac930641343b91b656e4e72c8f8325838b01a4b1c9d45" -dependencies = [ - "http", - "log", - "url", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line", - "cc", - "cfg-if 1.0.0", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", - "serde", -] - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" - -[[package]] -name = "base64ct" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b4d9b1225d28d360ec6a231d65af1fd99a2a095154c8040689617290569c5c" - -[[package]] -name = "bcs" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b6598a2f5d564fb7855dc6b06fd1c38cff5a72bd8b863a4d021938497b440a" -dependencies = [ - "serde", - "thiserror", -] - -[[package]] -name = "bevy" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91c6d3ec4f89e85294dc97334c5b271ddc301fdf67ac9bb994fe44d9273e6ed7" -dependencies = [ - "bevy_internal", -] - -[[package]] -name = "bevy_a11y" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "132c9e35a77c5395951f6d25fa2c52ee92296353426df4f961e60f3ff47e2e42" -dependencies = [ - "accesskit", - "bevy_app", - "bevy_derive", - "bevy_ecs", -] - -[[package]] -name = "bevy_animation" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f44eae3f1c35a87e38ad146f72317f19ce7616dad8bbdfb88ee752c1282d28c5" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_core", - "bevy_ecs", - "bevy_hierarchy", - "bevy_math", - "bevy_reflect", - "bevy_render", - "bevy_time", - "bevy_transform", - "bevy_utils", -] - -[[package]] -name = "bevy_app" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557a7d59e1e16892d7544fc37316506ee598cb5310ef0365125a30783c11531" -dependencies = [ - "bevy_derive", - "bevy_ecs", - "bevy_reflect", - "bevy_tasks", - "bevy_utils", - "downcast-rs", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "bevy_asset" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9714af523da4cdf58c42a317e5ed40349708ad954a18533991fd64c8ae0a6f68" -dependencies = [ - "anyhow", - "async-channel", - "bevy_app", - "bevy_diagnostic", - "bevy_ecs", - "bevy_log", - "bevy_reflect", - "bevy_tasks", - "bevy_utils", - "bevy_winit", - "crossbeam-channel 0.5.8", - "downcast-rs", - "fastrand 1.9.0", - "js-sys", - "notify", - "parking_lot 0.12.1", - "serde", - "thiserror", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "bevy_audio" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de308bd63a2f7a0b77ffeb7cf00cc185ec01393c5db2091fe03964f97152749" -dependencies = [ - "anyhow", - "bevy_app", - "bevy_asset", - "bevy_derive", - "bevy_ecs", - "bevy_math", - "bevy_reflect", - "bevy_transform", - "bevy_utils", - "oboe", - "parking_lot 0.12.1", - "rodio", -] - -[[package]] -name = "bevy_core" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d5272321be5fcf5ce2fb16023bc825bb10dfcb71611117296537181ce950f48" -dependencies = [ - "bevy_app", - "bevy_ecs", - "bevy_math", - "bevy_reflect", - "bevy_tasks", - "bevy_utils", - "bytemuck", -] - -[[package]] -name = "bevy_core_pipeline" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67382fa9c96ce4f4e5833ed7cedd9886844a8f3284b4a717bd4ac738dcdea0c3" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_core", - "bevy_derive", - "bevy_ecs", - "bevy_math", - "bevy_reflect", - "bevy_render", - "bevy_transform", - "bevy_utils", - "bitflags 2.4.1", - "radsort", - "serde", -] - -[[package]] -name = "bevy_derive" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44e4e2784a81430199e4157e02903a987a32127c773985506f020e7d501b62e" -dependencies = [ - "bevy_macro_utils", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "bevy_diagnostic" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6babb230dc383c98fdfc9603e3a7a2a49e1e2879dbe8291059ef37dca897932e" -dependencies = [ - "bevy_app", - "bevy_core", - "bevy_ecs", - "bevy_log", - "bevy_time", - "bevy_utils", - "sysinfo", -] - -[[package]] -name = "bevy_ecs" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266144b36df7e834d5198049e037ecdf2a2310a76ce39ed937d1b0a6a2c4e8c6" -dependencies = [ - "async-channel", - "bevy_ecs_macros", - "bevy_ptr", - "bevy_reflect", - "bevy_tasks", - "bevy_utils", - "downcast-rs", - "event-listener", - "fixedbitset", - "rustc-hash", - "serde", - "thiserror", - "thread_local", -] - -[[package]] -name = "bevy_ecs_macros" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7157a9c3be038d5008ee3f114feb6cf6b39c1d3d32ee21a7cacb8f81fccdfa80" -dependencies = [ - "bevy_macro_utils", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "bevy_encase_derive" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ac0f55ad6bca1be7b0f35bbd5fc95ed3d31e4e9db158fee8e5327f59006001" -dependencies = [ - "bevy_macro_utils", - "encase_derive_impl", -] - -[[package]] -name = "bevy_gilrs" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65f4d79c55829f8016014593a42453f61a564ffb06ef79460d25696ccdfac67b" -dependencies = [ - "bevy_app", - "bevy_ecs", - "bevy_input", - "bevy_log", - "bevy_time", - "bevy_utils", - "gilrs", - "thiserror", -] - -[[package]] -name = "bevy_gizmos" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e286a3e7276431963f4aa29165ea5429fa7dbbc6d5c5ba0c531e7dd44ecc88a2" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_core", - "bevy_core_pipeline", - "bevy_ecs", - "bevy_math", - "bevy_pbr", - "bevy_reflect", - "bevy_render", - "bevy_sprite", - "bevy_transform", - "bevy_utils", -] - -[[package]] -name = "bevy_gltf" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f07494a733dca032e71a20f4b1f423de765da49cbff34406ae6cd813f9b50c41" -dependencies = [ - "anyhow", - "base64 0.13.1", - "bevy_animation", - "bevy_app", - "bevy_asset", - "bevy_core", - "bevy_core_pipeline", - "bevy_ecs", - "bevy_hierarchy", - "bevy_log", - "bevy_math", - "bevy_pbr", - "bevy_reflect", - "bevy_render", - "bevy_scene", - "bevy_tasks", - "bevy_transform", - "bevy_utils", - "gltf", - "percent-encoding", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "bevy_hierarchy" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "103f8f58416ac6799b8c7f0b418f1fac9eba44fa924df3b0e16b09256b897e3d" -dependencies = [ - "bevy_app", - "bevy_core", - "bevy_ecs", - "bevy_log", - "bevy_reflect", - "bevy_utils", - "smallvec 1.11.1", -] - -[[package]] -name = "bevy_input" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbd935401101ac8003f3c3aea70788c65ad03f7a32716a10608bedda7a648bc" -dependencies = [ - "bevy_app", - "bevy_ecs", - "bevy_math", - "bevy_reflect", - "bevy_utils", - "thiserror", -] - -[[package]] -name = "bevy_internal" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0e35a9b2bd29aa784b3cc416bcbf2a298f69f00ca51fd042ea39d9af7fad37e" -dependencies = [ - "bevy_a11y", - "bevy_animation", - "bevy_app", - "bevy_asset", - "bevy_audio", - "bevy_core", - "bevy_core_pipeline", - "bevy_derive", - "bevy_diagnostic", - "bevy_ecs", - "bevy_gilrs", - "bevy_gizmos", - "bevy_gltf", - "bevy_hierarchy", - "bevy_input", - "bevy_log", - "bevy_math", - "bevy_pbr", - "bevy_ptr", - "bevy_reflect", - "bevy_render", - "bevy_scene", - "bevy_sprite", - "bevy_tasks", - "bevy_text", - "bevy_time", - "bevy_transform", - "bevy_ui", - "bevy_utils", - "bevy_window", - "bevy_winit", -] - -[[package]] -name = "bevy_log" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07dcc615ff4f617b06c3f9522fca3c55d56f9644db293318f8ab68fcdea5d4fe" -dependencies = [ - "android_log-sys", - "bevy_app", - "bevy_ecs", - "bevy_utils", - "console_error_panic_hook", - "tracing-log", - "tracing-subscriber", - "tracing-wasm", -] - -[[package]] -name = "bevy_macro_utils" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ddc18d489b4e57832d4958cde7cd2f349f0ad91e5892ac9e2f2ee16546b981" -dependencies = [ - "quote 1.0.33", - "rustc-hash", - "syn 2.0.38", - "toml_edit", -] - -[[package]] -name = "bevy_math" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78286a81fead796dc4b45ab14f4f02fe29a94423d3587bcfef872b2a8e0a474b" -dependencies = [ - "glam", - "serde", -] - -[[package]] -name = "bevy_mikktspace" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cfc2a21ea47970a9b1f0f4735af3256a8f204815bd756110051d10f9d909497" -dependencies = [ - "glam", -] - -[[package]] -name = "bevy_pbr" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63ca796a619e61cd43a0a3b11fde54644f7f0732a1fba1eef5d406248c6eba85" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_core_pipeline", - "bevy_derive", - "bevy_ecs", - "bevy_math", - "bevy_reflect", - "bevy_render", - "bevy_transform", - "bevy_utils", - "bevy_window", - "bitflags 2.4.1", - "bytemuck", - "naga_oil", - "radsort", -] - -[[package]] -name = "bevy_ptr" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c7586401a46f7d8e436028225c1df5288f2e0082d066b247a82466fea155c6" - -[[package]] -name = "bevy_reflect" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0778197a1eb3e095a71417c74b7152ede02975cdc95b5ea4ddc5251ed00a2eb5" -dependencies = [ - "bevy_math", - "bevy_ptr", - "bevy_reflect_derive", - "bevy_utils", - "downcast-rs", - "erased-serde", - "glam", - "once_cell", - "parking_lot 0.12.1", - "serde", - "smallvec 1.11.1", - "smol_str", - "thiserror", -] - -[[package]] -name = "bevy_reflect_derive" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "342a4b2d09db22c48607d23ad59a056aff1ee004549050a51d490d375ba29528" -dependencies = [ - "bevy_macro_utils", - "bit-set 0.5.3", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", - "uuid", -] - -[[package]] -name = "bevy_render" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39df4824b760928c27afc7b00fb649c7a63c9d76661ab014ff5c86537ee906cb" -dependencies = [ - "anyhow", - "async-channel", - "bevy_app", - "bevy_asset", - "bevy_core", - "bevy_derive", - "bevy_ecs", - "bevy_encase_derive", - "bevy_hierarchy", - "bevy_log", - "bevy_math", - "bevy_mikktspace", - "bevy_reflect", - "bevy_render_macros", - "bevy_tasks", - "bevy_time", - "bevy_transform", - "bevy_utils", - "bevy_window", - "bitflags 2.4.1", - "bytemuck", - "codespan-reporting", - "downcast-rs", - "encase", - "futures-lite", - "hexasphere", - "image", - "js-sys", - "ktx2", - "naga", - "naga_oil", - "parking_lot 0.12.1", - "regex", - "ruzstd", - "serde", - "smallvec 1.11.1", - "thiserror", - "thread_local", - "wasm-bindgen", - "web-sys", - "wgpu", - "wgpu-hal", -] - -[[package]] -name = "bevy_render_macros" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd08c740aac73363e32fb45af869b10cec65bcb76fe3e6cd0f8f7eebf4c36c9" -dependencies = [ - "bevy_macro_utils", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "bevy_scene" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd47e1263506153bef3a8be97fe2d856f206d315668c4f97510ca6cc181d9681" -dependencies = [ - "anyhow", - "bevy_app", - "bevy_asset", - "bevy_derive", - "bevy_ecs", - "bevy_hierarchy", - "bevy_reflect", - "bevy_render", - "bevy_transform", - "bevy_utils", - "ron", - "serde", - "thiserror", - "uuid", -] - -[[package]] -name = "bevy_sprite" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a8ca824fad75c6ef74cfbbba0a4ce3ccc435fa23d6bf3f003f260548813397" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_core_pipeline", - "bevy_derive", - "bevy_ecs", - "bevy_log", - "bevy_math", - "bevy_reflect", - "bevy_render", - "bevy_transform", - "bevy_utils", - "bitflags 2.4.1", - "bytemuck", - "fixedbitset", - "guillotiere", - "rectangle-pack", - "thiserror", -] - -[[package]] -name = "bevy_tasks" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c73bbb847c83990d3927005090df52f8ac49332e1643d2ad9aac3cd2974e66bf" -dependencies = [ - "async-channel", - "async-executor", - "async-task", - "concurrent-queue", - "futures-lite", - "wasm-bindgen-futures", -] - -[[package]] -name = "bevy_text" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692288ab7b0a9f8b38058964c52789fc6bcb63703b23de51cce90ec41bfca355" -dependencies = [ - "ab_glyph", - "anyhow", - "bevy_app", - "bevy_asset", - "bevy_ecs", - "bevy_math", - "bevy_reflect", - "bevy_render", - "bevy_sprite", - "bevy_transform", - "bevy_utils", - "bevy_window", - "glyph_brush_layout", - "serde", - "thiserror", -] - -[[package]] -name = "bevy_time" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d58d6dbae9c8225d8c0e0f04d2c5dbb71d22adc01ecd5ab3cebc364139e4a6d" -dependencies = [ - "bevy_app", - "bevy_ecs", - "bevy_reflect", - "bevy_utils", - "crossbeam-channel 0.5.8", - "thiserror", -] - -[[package]] -name = "bevy_transform" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9b0ac0149a57cd846cb357a35fc99286f9848e53d4481954608ac9552ed2d4" -dependencies = [ - "bevy_app", - "bevy_ecs", - "bevy_hierarchy", - "bevy_math", - "bevy_reflect", -] - -[[package]] -name = "bevy_ui" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b6d295a755e5b79e869a09e087029d72974562a521ec7ccfba7141fa948a32" -dependencies = [ - "bevy_a11y", - "bevy_app", - "bevy_asset", - "bevy_core_pipeline", - "bevy_derive", - "bevy_ecs", - "bevy_hierarchy", - "bevy_input", - "bevy_log", - "bevy_math", - "bevy_reflect", - "bevy_render", - "bevy_sprite", - "bevy_text", - "bevy_transform", - "bevy_utils", - "bevy_window", - "bytemuck", - "serde", - "smallvec 1.11.1", - "taffy", - "thiserror", -] - -[[package]] -name = "bevy_utils" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d9484e32434ea84dc548cff246ce0c6f756c1336f5ea03f24ac120a48595c7" -dependencies = [ - "ahash 0.8.3", - "bevy_utils_proc_macros", - "getrandom 0.2.10", - "hashbrown 0.14.1", - "instant", - "petgraph", - "thiserror", - "tracing", - "uuid", -] - -[[package]] -name = "bevy_utils_proc_macros" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5391b242c36f556db01d5891444730c83aa9dd648b6a8fd2b755d22cb3bddb57" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "bevy_window" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd584c0da7c4ada6557b09f57f30fb7cff21ccedc641473fc391574b4c9b7944" -dependencies = [ - "bevy_app", - "bevy_ecs", - "bevy_input", - "bevy_math", - "bevy_reflect", - "bevy_utils", - "raw-window-handle", -] - -[[package]] -name = "bevy_winit" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdc044abdb95790c20053e6326760f0a2985f0dcd78613d397bf35f16039d53" -dependencies = [ - "accesskit_winit", - "approx", - "bevy_a11y", - "bevy_app", - "bevy_derive", - "bevy_ecs", - "bevy_hierarchy", - "bevy_input", - "bevy_math", - "bevy_tasks", - "bevy_utils", - "bevy_window", - "crossbeam-channel 0.5.8", - "raw-window-handle", - "wasm-bindgen", - "web-sys", - "winit", -] - -[[package]] -name = "bindgen" -version = "0.64.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" -dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2 1.0.69", - "quote 1.0.33", - "regex", - "rustc-hash", - "shlex", - "syn 1.0.109", -] - -[[package]] -name = "bindgen" -version = "0.68.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" -dependencies = [ - "bitflags 2.4.1", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "proc-macro2 1.0.69", - "quote 1.0.33", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.38", -] - -[[package]] -name = "bit-set" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c" -dependencies = [ - "bit-vec 0.4.4", -] - -[[package]] -name = "bit-set" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" -dependencies = [ - "bit-vec 0.6.3", -] - -[[package]] -name = "bit-vec" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" - -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" -dependencies = [ - "serde", -] - -[[package]] -name = "bitvec" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" -dependencies = [ - "either", - "radium 0.3.0", -] - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium 0.7.0", - "tap", - "wyz", -] - -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding", - "cipher 0.2.5", -] - -[[package]] -name = "block-modes" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" -dependencies = [ - "block-padding", - "cipher 0.3.0", -] - -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - -[[package]] -name = "block-sys" -version = "0.1.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146" -dependencies = [ - "objc-sys", -] - -[[package]] -name = "block2" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42" -dependencies = [ - "block-sys", - "objc2-encode", -] - -[[package]] -name = "blooms-db" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "byteorder", - "ethbloom 0.5.3", - "parking_lot 0.7.1", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "bls-signatures" -version = "0.15.0" -source = "git+https://github.com/Conflux-Chain/bls-signatures.git?rev=fb52187df92d27c365642cb7e7b2aaf60437cf9c#fb52187df92d27c365642cb7e7b2aaf60437cf9c" -dependencies = [ - "blst", - "blstrs", - "cfg-if 0.1.10", - "ff", - "group", - "pairing", - "rand_core 0.6.4", - "rayon", - "sha2 0.9.9", - "subtle", - "thiserror", -] - -[[package]] -name = "blst" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" -dependencies = [ - "cc", - "glob", - "threadpool", - "zeroize", -] - -[[package]] -name = "blstrs" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" -dependencies = [ - "blst", - "byte-slice-cast 1.2.2", - "ff", - "group", - "pairing", - "rand_core 0.6.4", - "serde", - "subtle", -] - -[[package]] -name = "bn" -version = "0.4.4" -source = "git+https://github.com/Conflux-Chain/bn.git?rev=635c4cdd560bc0c8b262e6bf809dc709da8bcd7e#635c4cdd560bc0c8b262e6bf809dc709da8bcd7e" -dependencies = [ - "byteorder", - "crunchy 0.2.2", - "lazy_static", - "rand 0.5.6", - "rustc-hex 2.1.0", -] - -[[package]] -name = "bounded-executor" -version = "0.1.0" -dependencies = [ - "futures 0.3.28", - "tokio 1.33.0", -] - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "byte-slice-cast" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - -[[package]] -name = "byte-unit" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e447b884b73b7d27c8d9e58a8b8b0ebd640dbf7dcd63393db9a359cb455d441" -dependencies = [ - "lazy_static", - "regex", -] - -[[package]] -name = "bytemuck" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" -dependencies = [ - "bytemuck_derive", -] - -[[package]] -name = "bytemuck_derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "git+https://github.com/alexcrichton/bzip2-rs.git#3032f3790742bffda521e54d14429f459e078eba" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - -[[package]] -name = "c_linked_list" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" - -[[package]] -name = "cached-pos-ledger-db" -version = "0.1.0" -dependencies = [ - "anyhow", - "consensus-types", - "diem-crypto", - "diem-infallible", - "diem-logger", - "diem-types", - "executor-types", - "pos-ledger-db", - "serde", - "storage-interface", -] - -[[package]] -name = "cc" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "jobserver", - "libc", -] - -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - -[[package]] -name = "cfx-addr" -version = "0.1.0" -dependencies = [ - "cfx-types", - "lazy_static", - "rustc-hex 2.1.0", -] - -[[package]] -name = "cfx-bytes" -version = "0.1.0" -dependencies = [ - "ethcore-bytes", -] - -[[package]] -name = "cfx-internal-common" -version = "1.0.0" -dependencies = [ - "cfx-bytes", - "cfx-parameters", - "cfx-types", - "derivative", - "lazy_static", - "log", - "malloc_size_of", - "malloc_size_of_derive", - "parking_lot 0.11.2", - "primitives", - "rlp 0.4.6", - "rlp_derive 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", - "serde", - "serde_derive", - "toml", -] - -[[package]] -name = "cfx-math" -version = "0.1.0" -dependencies = [ - "cfx-types", - "num 0.2.1", - "typenum", - "unroll", -] - -[[package]] -name = "cfx-packing-pool" -version = "0.1.0" -dependencies = [ - "cfx-math", - "cfx-types", - "heap-map", - "malloc_size_of", - "malloc_size_of_derive", - "primitives", - "rand 0.7.3", - "rand_xorshift 0.2.0", - "treap-map", - "typenum", -] - -[[package]] -name = "cfx-parameters" -version = "1.0.0" -dependencies = [ - "cfx-types", - "hex-literal", - "lazy_static", -] - -[[package]] -name = "cfx-state" -version = "1.0.0" -dependencies = [ - "cfx-internal-common", - "cfx-parameters", - "cfx-statedb", - "cfx-storage", - "cfx-types", - "keccak-hash 0.5.1", - "parking_lot 0.11.2", - "primitives", - "rlp 0.4.6", -] - -[[package]] -name = "cfx-statedb" -version = "1.0.0" -dependencies = [ - "cfx-internal-common", - "cfx-parameters", - "cfx-storage", - "cfx-types", - "error-chain", - "hashbrown 0.7.2", - "lazy_static", - "log", - "parking_lot 0.11.2", - "primitives", - "rlp 0.4.6", - "tiny-keccak 2.0.2", -] - -[[package]] -name = "cfx-storage" -version = "1.0.0" -dependencies = [ - "cfg-if 0.1.10", - "cfx-bytes", - "cfx-internal-common", - "cfx-types", - "delegate", - "derivative", - "error-chain", - "fallible-iterator", - "fs_extra", - "futures 0.3.28", - "hashbrown 0.7.2", - "keccak-hash 0.5.1", - "kvdb 0.4.0", - "kvdb-rocksdb", - "lazy_static", - "log", - "log4rs", - "malloc_size_of", - "malloc_size_of_derive", - "memoffset 0.5.6", - "once_cell", - "parity-util-mem", - "parking_lot 0.11.2", - "primitives", - "rand 0.7.3", - "rand_chacha 0.2.2", - "random-crash", - "rlp 0.4.6", - "rlp_derive 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", - "rustc-hex 2.1.0", - "serde", - "serde_derive", - "sqlite", - "sqlite3-sys", - "strfmt", - "tokio 0.2.25", -] - -[[package]] -name = "cfx-types" -version = "0.2.0" -dependencies = [ - "ethereum-types 0.9.2", - "rlp 0.4.6", - "rlp_derive 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", - "serde", - "serde_derive", -] - -[[package]] -name = "cfx-utils" -version = "0.6.0" -dependencies = [ - "log", - "parking_lot 0.11.2", -] - -[[package]] -name = "cfxcore" -version = "2.3.4-2-beta" -dependencies = [ - "anyhow", - "async-oneshot", - "async-trait", - "bcs", - "bit-set 0.4.0", - "bls-signatures", - "bounded-executor", - "byteorder", - "cached-pos-ledger-db", - "cfx-addr", - "cfx-bytes", - "cfx-internal-common", - "cfx-math", - "cfx-packing-pool", - "cfx-parameters", - "cfx-state", - "cfx-statedb", - "cfx-storage", - "cfx-types", - "cfx-utils", - "cfxkey", - "channel", - "clap", - "consensus-types", - "crash-handler", - "dag", - "db", - "derivative", - "diem-config", - "diem-crypto", - "diem-infallible", - "diem-logger", - "diem-metrics", - "diem-secure-storage", - "diem-temppath", - "diem-types", - "either", - "error-chain", - "executor", - "executor-types", - "fail", - "fallible", - "fallible-iterator", - "fs_extra", - "futures 0.3.28", - "hashbrown 0.7.2", - "heap-map", - "hibitset", - "io", - "itertools 0.9.0", - "jsonrpc-core", - "keccak-hash 0.5.1", - "kvdb 0.4.0", - "kvdb-rocksdb", - "lazy_static", - "link-cut-tree", - "log", - "log4rs", - "lru_time_cache", - "malloc_size_of", - "malloc_size_of_derive", - "memmap", - "memoffset 0.5.6", - "memory-cache 0.1.0", - "metrics", - "mirai-annotations", - "move-core-types", - "network", - "num 0.2.1", - "num-derive", - "num-traits", - "once_cell", - "parity-crypto 0.9.0", - "parity-util-mem", - "parking_lot 0.11.2", - "pos-ledger-db", - "pow-types", - "primal", - "primitives", - "priority-send-queue", - "prometheus 0.7.0", - "rand 0.7.3", - "rand 0.8.5", - "rand_xorshift 0.2.0", - "random-crash", - "rayon", - "rlp 0.4.6", - "rlp_derive 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", - "rustc-hex 2.1.0", - "safety-rules", - "schemadb", - "secret-store", - "serde", - "serde_derive", - "serde_json", - "sha3-macro", - "short-hex-str", - "siphasher 0.3.11", - "slab", - "smart-default", - "solidity-abi", - "solidity-abi-derive", - "sqlite", - "sqlite3-sys", - "static_assertions", - "storage-interface", - "strfmt", - "strum 0.20.0", - "strum_macros 0.20.1", - "subscription-service", - "substrate-bn", - "tempdir", - "thiserror", - "threadpool", - "throttling", - "tiny-keccak 2.0.2", - "tokio 0.2.25", - "tokio 1.33.0", - "tokio-stream", - "tokio-timer", - "toml", - "treap-map", - "unexpected 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", -] - -[[package]] -name = "cfxkey" -version = "0.3.0" -dependencies = [ - "cfx-types", - "edit-distance", - "lazy_static", - "log", - "malloc_size_of", - "malloc_size_of_derive", - "parity-crypto 0.9.0", - "parity-secp256k1", - "parity-wordlist", - "quick-error", - "rand 0.7.3", - "rustc-hex 2.1.0", - "serde", - "serde_derive", - "tiny-keccak 1.5.0", - "zeroize", -] - -[[package]] -name = "channel" -version = "0.1.0" -dependencies = [ - "anyhow", - "diem-infallible", - "diem-metrics", - "futures 0.3.28", -] - -[[package]] -name = "chrono" -version = "0.4.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "time", - "wasm-bindgen", - "winapi 0.3.9", -] - -[[package]] -name = "chunked_transfer" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca491388666e04d7248af3f60f0c40cfb0991c72205595d7c396e3510207d1a" - -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array", -] - -[[package]] -name = "clang-sys" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" -dependencies = [ - "glob", - "libc", - "libloading 0.7.4", -] - -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term 0.12.1", - "atty", - "bitflags 1.3.2", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - -[[package]] -name = "com-rs" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642" - -[[package]] -name = "combine" -version = "4.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" -dependencies = [ - "bytes 1.5.0", - "memchr", -] - -[[package]] -name = "common-types" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ethereum-types 0.4.2", - "ethjson", - "ethkey", - "heapsize", - "keccak-hash 0.1.2", - "parity-bytes", - "parity-machine", - "rlp 0.3.0", - "rlp_derive 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", - "unexpected 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", -] - -[[package]] -name = "concurrent-queue" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" -dependencies = [ - "crossbeam-utils 0.8.16", -] - -[[package]] -name = "consensus-types" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "diem-crypto", - "diem-crypto-derive", - "diem-infallible", - "diem-types", - "executor-types", - "mirai-annotations", - "rustc-hex 2.1.0", - "serde", - "short-hex-str", -] - -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen", -] - -[[package]] -name = "const-oid" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" - -[[package]] -name = "const_panic" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6051f239ecec86fde3410901ab7860d458d160371533842974fc61f96d15879b" - -[[package]] -name = "const_soft_float" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ca1caa64ef4ed453e68bb3db612e51cf1b2f5b871337f0fcab1c8f87cc3dff" - -[[package]] -name = "constgebra" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd23e864550e6dafc1e41ac78ce4f1ccddc8672b40c403524a04ff3f0518420" -dependencies = [ - "const_soft_float", -] - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - -[[package]] -name = "core-graphics" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types", - "libc", -] - -[[package]] -name = "core-graphics-types" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "libc", -] - -[[package]] -name = "coreaudio-rs" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" -dependencies = [ - "bitflags 1.3.2", - "core-foundation-sys", - "coreaudio-sys", -] - -[[package]] -name = "coreaudio-sys" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8478e5bdad14dce236b9898ea002eabfa87cbe14f0aa538dbe3b6a4bec4332d" -dependencies = [ - "bindgen 0.68.1", -] - -[[package]] -name = "cpal" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d959d90e938c5493000514b446987c07aed46c668faaa7d34d6c7a67b1a578c" -dependencies = [ - "alsa", - "core-foundation-sys", - "coreaudio-rs", - "dasp_sample", - "jni 0.19.0", - "js-sys", - "libc", - "mach2", - "ndk", - "ndk-context", - "oboe", - "once_cell", - "parking_lot 0.12.1", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows 0.46.0", -] - -[[package]] -name = "cpufeatures" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" -dependencies = [ - "libc", -] - -[[package]] -name = "cpuid-bool" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - -[[package]] -name = "crash-handler" -version = "0.1.0" -dependencies = [ - "backtrace", - "diem-logger", - "serde", - "toml", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7408247b1b87f480890f28b670c5f8d9a8a4274833433fe74dc0dfd46d33650" -dependencies = [ - "crossbeam-channel 0.2.6", - "crossbeam-deque 0.5.2", - "crossbeam-epoch 0.5.2", - "crossbeam-utils 0.5.0", -] - -[[package]] -name = "crossbeam-channel" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827" -dependencies = [ - "crossbeam-epoch 0.6.1", - "crossbeam-utils 0.5.0", - "parking_lot 0.6.4", - "rand 0.5.6", - "smallvec 0.6.14", -] - -[[package]] -name = "crossbeam-channel" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" -dependencies = [ - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils 0.8.16", -] - -[[package]] -name = "crossbeam-deque" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7792c4a9b5a4222f654e3728a3dd945aacc24d2c3a1a096ed265d80e4929cb9a" -dependencies = [ - "crossbeam-epoch 0.5.2", - "crossbeam-utils 0.5.0", -] - -[[package]] -name = "crossbeam-deque" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" -dependencies = [ - "crossbeam-epoch 0.7.2", - "crossbeam-utils 0.6.6", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" -dependencies = [ - "crossbeam-epoch 0.8.2", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-epoch 0.9.15", - "crossbeam-utils 0.8.16", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30fecfcac6abfef8771151f8be4abc9e4edc112c2bcb233314cafde2680536e9" -dependencies = [ - "arrayvec 0.4.12", - "cfg-if 0.1.10", - "crossbeam-utils 0.5.0", - "lazy_static", - "memoffset 0.2.1", - "scopeguard 0.3.3", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8" -dependencies = [ - "arrayvec 0.4.12", - "cfg-if 0.1.10", - "crossbeam-utils 0.6.6", - "lazy_static", - "memoffset 0.2.1", - "scopeguard 0.3.3", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" -dependencies = [ - "arrayvec 0.4.12", - "cfg-if 0.1.10", - "crossbeam-utils 0.6.6", - "lazy_static", - "memoffset 0.5.6", - "scopeguard 1.2.0", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "lazy_static", - "maybe-uninit", - "memoffset 0.5.6", - "scopeguard 1.2.0", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 1.0.0", - "crossbeam-utils 0.8.16", - "memoffset 0.9.0", - "scopeguard 1.2.0", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-utils" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" - -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -dependencies = [ - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg 1.1.0", - "cfg-if 0.1.10", - "lazy_static", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crunchy" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "crypto-mac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "crypto-mac" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" -dependencies = [ - "cipher 0.2.5", -] - -[[package]] -name = "curve25519-dalek-fiat" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44339b9ecede7f72a0d3b012bf9bb5a616dc8bfde23ce544e42da075c87198f0" -dependencies = [ - "byteorder", - "digest 0.9.0", - "fiat-crypto", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "d3d12" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f0de2f5a8e7bd4a9eec0e3c781992a4ce1724f68aec7d7a3715344de8b39da" -dependencies = [ - "bitflags 1.3.2", - "libloading 0.7.4", - "winapi 0.3.9", -] - -[[package]] -name = "dag" -version = "0.1.0" -dependencies = [ - "hibitset", -] - -[[package]] -name = "dasp_sample" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" - -[[package]] -name = "data-encoding" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" - -[[package]] -name = "db" -version = "0.1.0" -dependencies = [ - "kvdb 0.4.0", - "kvdb-rocksdb", - "log", -] - -[[package]] -name = "delegate" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd733b5bf0bb5ca3c7cdea2135c91234c80b730e6e8a270851455a63b46c830" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "der" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" -dependencies = [ - "const-oid", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "destructure_traitobject" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" - -[[package]] -name = "diem-config" -version = "0.1.0" -dependencies = [ - "bcs", - "cfx-types", - "diem-crypto", - "diem-crypto-derive", - "diem-global-constants", - "diem-logger", - "diem-network-address-encryption", - "diem-secure-storage", - "diem-temppath", - "diem-types", - "get_if_addrs", - "log", - "mirai-annotations", - "rand 0.8.5", - "serde", - "serde_yaml", - "short-hex-str", - "thiserror", -] - -[[package]] -name = "diem-crypto" -version = "0.1.0" -dependencies = [ - "aes-gcm", - "anyhow", - "bcs", - "bls-signatures", - "bytes 1.5.0", - "cfx-types", - "cfxkey", - "curve25519-dalek-fiat", - "diem-crypto-derive", - "diem-logger", - "digest 0.9.0", - "ed25519-dalek-fiat", - "hex", - "hkdf", - "lazy_static", - "mirai-annotations", - "once_cell", - "openssl", - "parking_lot 0.11.2", - "pkcs8", - "rand 0.8.5", - "rand_core 0.5.1", - "serde", - "serde-name", - "serde_bytes", - "sha2 0.9.9", - "static_assertions", - "thiserror", - "tiny-keccak 2.0.2", - "vrf", - "x25519-dalek-fiat", -] - -[[package]] -name = "diem-crypto-derive" -version = "0.1.0" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "diem-github-client" -version = "0.1.0" -dependencies = [ - "proxy", - "serde", - "serde_json", - "thiserror", - "ureq", -] - -[[package]] -name = "diem-global-constants" -version = "0.1.0" - -[[package]] -name = "diem-infallible" -version = "0.1.0" - -[[package]] -name = "diem-jellyfish-merkle" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "byteorder", - "diem-crypto", - "diem-crypto-derive", - "diem-infallible", - "diem-metrics", - "diem-nibble", - "diem-types", - "mirai-annotations", - "num-derive", - "num-traits", - "once_cell", - "serde", - "thiserror", -] - -[[package]] -name = "diem-log-derive" -version = "0.1.0" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "diem-logger" -version = "0.1.0" -dependencies = [ - "backtrace", - "chrono", - "diem-infallible", - "diem-log-derive", - "erased-serde", - "hostname", - "once_cell", - "parking_lot 0.11.2", - "pipe-logger-lib", - "prometheus 0.12.0", - "serde", - "serde_json", -] - -[[package]] -name = "diem-metrics" -version = "0.1.0" -dependencies = [ - "anyhow", - "diem-logger", - "diem-metrics-core", - "futures 0.3.28", - "hyper", - "once_cell", - "prometheus 0.12.0", - "serde_json", - "tokio 1.33.0", -] - -[[package]] -name = "diem-metrics-core" -version = "0.1.0" -dependencies = [ - "prometheus 0.12.0", -] - -[[package]] -name = "diem-network-address-encryption" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "bcs", - "diem-global-constants", - "diem-infallible", - "diem-logger", - "diem-secure-storage", - "diem-types", - "serde", - "thiserror", -] - -[[package]] -name = "diem-nibble" -version = "0.1.0" -dependencies = [ - "serde", -] - -[[package]] -name = "diem-secure-net" -version = "0.1.0" -dependencies = [ - "diem-logger", - "diem-secure-push-metrics", - "once_cell", - "serde", - "thiserror", -] - -[[package]] -name = "diem-secure-push-metrics" -version = "0.1.0" -dependencies = [ - "diem-logger", - "diem-metrics-core", - "ureq", -] - -[[package]] -name = "diem-secure-storage" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "bcs", - "chrono", - "diem-crypto", - "diem-github-client", - "diem-infallible", - "diem-logger", - "diem-temppath", - "diem-time-service", - "diem-types", - "diem-vault-client", - "enum_dispatch", - "rand 0.8.5", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "diem-state-view" -version = "0.1.0" -dependencies = [ - "anyhow", - "diem-crypto", - "diem-types", -] - -[[package]] -name = "diem-temppath" -version = "0.1.0" -dependencies = [ - "hex", - "rand 0.8.5", -] - -[[package]] -name = "diem-time-service" -version = "0.1.0" -dependencies = [ - "diem-infallible", - "enum_dispatch", - "thiserror", -] - -[[package]] -name = "diem-types" -version = "0.1.0" -dependencies = [ - "aes-gcm", - "anyhow", - "bcs", - "bytes 1.5.0", - "cfx-types", - "chrono", - "diem-crypto", - "diem-crypto-derive", - "diem-logger", - "hex", - "itertools 0.10.5", - "mirai-annotations", - "move-core-types", - "once_cell", - "pow-types", - "rand 0.8.5", - "serde", - "serde_bytes", - "serde_json", - "static_assertions", - "thiserror", - "tiny-keccak 2.0.2", -] - -[[package]] -name = "diem-vault-client" -version = "0.1.0" -dependencies = [ - "base64 0.13.1", - "chrono", - "diem-crypto", - "diem-types", - "native-tls", - "once_cell", - "serde", - "serde_json", - "thiserror", - "ureq", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common", - "subtle", -] - -[[package]] -name = "dispatch" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" - -[[package]] -name = "downcast-rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" - -[[package]] -name = "ed25519" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" -dependencies = [ - "serde", - "signature", -] - -[[package]] -name = "ed25519-dalek-fiat" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97c6ac152eba578c1c53d2cefe8ad02e239e3d6f971b0f1ef3cb54cd66037fa0" -dependencies = [ - "curve25519-dalek-fiat", - "ed25519", - "rand 0.8.5", - "serde", - "serde_bytes", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "edit-distance" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbaaaf38131deb9ca518a274a45bfdb8771f139517b073b16c2d3d32ae5037b" - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "elastic-array" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" -dependencies = [ - "heapsize", -] - -[[package]] -name = "encase" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fce2eeef77fd4a293a54b62aa00ac9daebfbcda4bf8998c5a815635b004aa1c" -dependencies = [ - "const_panic", - "encase_derive", - "glam", - "thiserror", -] - -[[package]] -name = "encase_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e520cde08cbf4f7cc097f61573ec06ce467019803de8ae82fb2823fa1554a0e" -dependencies = [ - "encase_derive_impl", -] - -[[package]] -name = "encase_derive_impl" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fe2568f851fd6144a45fa91cfed8fe5ca8fc0b56ba6797bfc1ed2771b90e37c" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "encoding_rs" -version = "0.8.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "enum-map" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa1769f019df7ccd8f9a741d2d608309688d0f1bd8a8747c14ac993660c761c" -dependencies = [ - "array-macro", - "enum-map-derive", - "reexport-proc-macro", -] - -[[package]] -name = "enum-map-derive" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c450cf304c9e18d45db562025a14fb1ca0f5c769b6f609309f81d4c31de455" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "enum_dispatch" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f33313078bb8d4d05a2733a94ac4c2d8a0df9a2b84424ebf4f33bfc224a890e" -dependencies = [ - "once_cell", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "erased-serde" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" -dependencies = [ - "serde", -] - -[[package]] -name = "errno" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "error-chain" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" -dependencies = [ - "backtrace", - "version_check", -] - -[[package]] -name = "eth-secp256k1" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd3fb7567e8dbc89918e5f8906c336d4025c8da7e8d89e790477bfa2a9f79e0" -dependencies = [ - "arrayvec 0.4.12", - "cc", - "cfg-if 0.1.10", - "rand 0.4.6", -] - -[[package]] -name = "ethabi" -version = "6.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb362fde43ed0b50b258bb0c72b72b3dccfd29f8de9506295eaf9251c49ca31" -dependencies = [ - "error-chain", - "ethereum-types 0.4.2", - "rustc-hex 2.1.0", - "serde", - "serde_derive", - "serde_json", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "ethabi-contract" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "795e25fd868e12a59ca235dbe1f6cc8f1eba8f67d6a39438b29535e0126e0c27" - -[[package]] -name = "ethabi-derive" -version = "6.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a587250c8190be9d6ae28d67b8957ed97cb9eee2e272173a20593ab054a075" -dependencies = [ - "ethabi", - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "ethash" -version = "1.12.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "crunchy 0.1.6", - "either", - "ethereum-types 0.4.2", - "keccak-hash 0.1.2", - "log", - "memmap", - "parking_lot 0.7.1", - "primal", -] - -[[package]] -name = "ethbloom" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6294da962646baa738414e8e718d1a1f0360a51d92de89ccbf91870418f5360" -dependencies = [ - "crunchy 0.1.6", - "ethereum-types-serialize", - "fixed-hash 0.2.5", - "serde", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "ethbloom" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" -dependencies = [ - "crunchy 0.2.2", - "fixed-hash 0.6.1", - "impl-rlp", - "impl-serde", - "tiny-keccak 2.0.2", -] - -[[package]] -name = "ethcore" -version = "1.12.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ansi_term 0.10.2", - "bn", - "byteorder", - "common-types", - "crossbeam", - "error-chain", - "ethabi", - "ethabi-contract", - "ethabi-derive", - "ethash", - "ethcore-blockchain", - "ethcore-bloom-journal", - "ethcore-call-contract", - "ethcore-db", - "ethcore-io", - "ethcore-miner", - "ethereum-types 0.4.2", - "ethjson", - "ethkey", - "evm", - "hash-db", - "heapsize", - "itertools 0.5.10", - "journaldb", - "keccak-hash 0.1.2", - "keccak-hasher", - "kvdb 0.1.1", - "kvdb-memorydb", - "lazy_static", - "len-caching-lock", - "log", - "lru-cache", - "macros", - "memory-cache 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", - "memory-db", - "num 0.1.42", - "num_cpus", - "parity-bytes", - "parity-crypto 0.3.0", - "parity-machine", - "parity-snappy", - "parking_lot 0.7.1", - "patricia-trie-ethereum", - "rand 0.4.6", - "rayon", - "rlp 0.3.0", - "rlp_derive 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", - "rustc-hex 1.0.0", - "serde", - "serde_derive", - "stats", - "trace-time", - "trie-db", - "triehash-ethereum", - "unexpected 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", - "using_queue", - "vm", - "wasm", -] - -[[package]] -name = "ethcore-blockchain" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ansi_term 0.10.2", - "blooms-db", - "common-types", - "ethcore-db", - "ethereum-types 0.4.2", - "heapsize", - "itertools 0.5.10", - "kvdb 0.1.1", - "log", - "parity-bytes", - "parking_lot 0.7.1", - "rayon", - "rlp 0.3.0", - "rlp_compress", - "rlp_derive 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", -] - -[[package]] -name = "ethcore-bloom-journal" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "siphasher 0.1.3", -] - -[[package]] -name = "ethcore-bytes" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e957efe1e627f8ec4e253660615fd9fe3736e10026197740b8b4b26c812be2e9" - -[[package]] -name = "ethcore-call-contract" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "common-types", - "ethereum-types 0.4.2", - "parity-bytes", -] - -[[package]] -name = "ethcore-db" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "common-types", - "ethereum-types 0.4.2", - "heapsize", - "kvdb 0.1.1", - "parking_lot 0.7.1", - "rlp 0.3.0", - "rlp_derive 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", -] - -[[package]] -name = "ethcore-io" -version = "1.12.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "crossbeam-deque 0.6.3", - "fnv", - "futures 0.1.31", - "log", - "num_cpus", - "parking_lot 0.7.1", - "slab", - "time", - "timer", - "tokio 0.1.22", -] - -[[package]] -name = "ethcore-miner" -version = "1.12.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ansi_term 0.10.2", - "common-types", - "error-chain", - "ethabi", - "ethabi-contract", - "ethabi-derive", - "ethcore-call-contract", - "ethereum-types 0.4.2", - "futures 0.1.31", - "heapsize", - "keccak-hash 0.1.2", - "linked-hash-map", - "log", - "parity-runtime", - "parking_lot 0.7.1", - "rlp 0.3.0", - "trace-time", - "transaction-pool", -] - -[[package]] -name = "ethereum-types" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e742184dc63a01c8ea0637369f8faa27c40f537949908a237f95c05e68d2c96" -dependencies = [ - "crunchy 0.1.6", - "ethbloom 0.5.3", - "ethereum-types-serialize", - "fixed-hash 0.2.5", - "serde", - "uint 0.4.1", -] - -[[package]] -name = "ethereum-types" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" -dependencies = [ - "ethbloom 0.9.2", - "fixed-hash 0.6.1", - "impl-rlp", - "impl-serde", - "primitive-types", - "uint 0.8.5", -] - -[[package]] -name = "ethereum-types-serialize" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1873d77b32bc1891a79dad925f2acbc318ee942b38b9110f9dbc5fbeffcea350" -dependencies = [ - "serde", -] - -[[package]] -name = "ethjson" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ethereum-types 0.4.2", - "rustc-hex 1.0.0", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "ethkey" -version = "0.3.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "byteorder", - "edit-distance", - "eth-secp256k1", - "ethereum-types 0.4.2", - "lazy_static", - "log", - "memzero", - "parity-crypto 0.3.0", - "parity-wordlist", - "quick-error", - "rand 0.4.6", - "rustc-hex 1.0.0", - "serde", - "serde_derive", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "euclid" -version = "0.22.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f253bc5c813ca05792837a0ff4b3a580336b224512d48f7eda1d7dd9210787" -dependencies = [ - "num-traits", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "evm" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "bit-set 0.4.0", - "ethereum-types 0.4.2", - "heapsize", - "keccak-hash 0.1.2", - "lazy_static", - "log", - "memory-cache 0.1.0 (git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0)", - "parity-bytes", - "parking_lot 0.7.1", - "vm", -] - -[[package]] -name = "executor" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "bcs", - "cached-pos-ledger-db", - "cfx-types", - "consensus-types", - "diem-crypto", - "diem-infallible", - "diem-logger", - "diem-metrics", - "diem-secure-net", - "diem-state-view", - "diem-types", - "executor-types", - "fail", - "futures 0.3.28", - "itertools 0.10.5", - "move-core-types", - "once_cell", - "pow-types", - "scratchpad", - "serde", - "serde_json", - "storage-interface", - "subscription-service", -] - -[[package]] -name = "executor-types" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "diem-crypto", - "diem-secure-net", - "diem-types", - "scratchpad", - "serde", - "storage-interface", - "thiserror", -] - -[[package]] -name = "fail" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be3c61c59fdc91f5dbc3ea31ee8623122ce80057058be560654c5d410d181a6" -dependencies = [ - "lazy_static", - "log", - "rand 0.7.3", -] - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "fallible" -version = "0.1.0" -dependencies = [ - "thiserror", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fastmap" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ethereum-types 0.4.2", - "plain_hasher", -] - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "fdeflate" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" -dependencies = [ - "simd-adler32", -] - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "bitvec 1.0.1", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "fiat-crypto" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" - -[[package]] -name = "filetime" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", -] - -[[package]] -name = "fixed-hash" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7afe6ce860afb14422711595a7b26ada9ed7de2f43c0b2ab79d09ee196287273" -dependencies = [ - "heapsize", - "libc", - "rand 0.4.6", - "rustc-hex 2.1.0", -] - -[[package]] -name = "fixed-hash" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3367952ceb191f4ab95dd5685dc163ac539e36202f9fcfd0cb22f9f9c542fefc" -dependencies = [ - "byteorder", - "libc", - "rand 0.7.3", - "rustc-hex 2.1.0", - "static_assertions", -] - -[[package]] -name = "fixed-hash" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" -dependencies = [ - "byteorder", - "rand 0.7.3", - "rustc-hex 2.1.0", - "static_assertions", -] - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "flate2" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "fs-swap" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d47dad3685eceed8488986cad3d5027165ea5edb164331770e2059555f10a5" -dependencies = [ - "lazy_static", - "libc", - "libloading 0.5.2", - "winapi 0.3.9", -] - -[[package]] -name = "fs_extra" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" - -[[package]] -name = "fsevent-sys" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" -dependencies = [ - "libc", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags 1.3.2", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - -[[package]] -name = "futures" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-executor" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite 0.2.13", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "futures-micro" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b460264b3593d68b16a7bc35f7bc226ddfebdf9a1c8db1ed95d5cc6b7168c826" -dependencies = [ - "pin-project-lite 0.2.13", -] - -[[package]] -name = "futures-sink" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" - -[[package]] -name = "futures-task" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" - -[[package]] -name = "futures-util" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" -dependencies = [ - "futures 0.1.31", - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite 0.2.13", - "pin-utils", - "slab", -] - -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "get_if_addrs" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" -dependencies = [ - "c_linked_list", - "get_if_addrs-sys", - "libc", - "winapi 0.2.8", -] - -[[package]] -name = "get_if_addrs-sys" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" -dependencies = [ - "gcc", - "libc", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-bindgen", -] - -[[package]] -name = "ghash" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" -dependencies = [ - "opaque-debug", - "polyval", -] - -[[package]] -name = "gilrs" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62fd19844d0eb919aca41d3e4ea0e0b6bf60e1e827558b101c269015b8f5f27a" -dependencies = [ - "fnv", - "gilrs-core", - "log", - "uuid", - "vec_map", -] - -[[package]] -name = "gilrs-core" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccc99e9b8d63ffcaa334c4babfa31f46e156618a11f63efb6e8e6bcb37b830d" -dependencies = [ - "core-foundation", - "io-kit-sys", - "js-sys", - "libc", - "libudev-sys", - "log", - "nix 0.26.4", - "uuid", - "vec_map", - "wasm-bindgen", - "web-sys", - "windows 0.51.1", -] - -[[package]] -name = "gimli" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" - -[[package]] -name = "glam" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945" -dependencies = [ - "bytemuck", - "serde", -] - -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - -[[package]] -name = "glow" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0fe580e4b60a8ab24a868bc08e2f03cbcb20d3d676601fa909386713333728" -dependencies = [ - "js-sys", - "slotmap", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gltf" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2dcfb6dd7a66f9eb3d181a29dcfb22d146b0bcdc2e1ed1713cbf03939a88ea" -dependencies = [ - "byteorder", - "gltf-json", - "lazy_static", -] - -[[package]] -name = "gltf-derive" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cbcea5dd47e7ad4e9ee6f040384fcd7204bbf671aa4f9e7ca7dfc9bfa1de20" -dependencies = [ - "inflections", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "gltf-json" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5b810806b78dde4b71a95cc0e6fdcab34c4c617da3574df166f9987be97d03" -dependencies = [ - "gltf-derive", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "glyph_brush_layout" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc32c2334f00ca5ac3695c5009ae35da21da8c62d255b5b96d56e2597a637a38" -dependencies = [ - "ab_glyph", - "approx", - "xi-unicode", -] - -[[package]] -name = "gpu-alloc" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22beaafc29b38204457ea030f6fb7a84c9e4dd1b86e311ba0542533453d87f62" -dependencies = [ - "bitflags 1.3.2", - "gpu-alloc-types", -] - -[[package]] -name = "gpu-alloc-types" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54804d0d6bc9d7f26db4eaec1ad10def69b599315f487d32c334a80d1efe67a5" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "gpu-allocator" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce95f9e2e11c2c6fadfce42b5af60005db06576f231f5c92550fdded43c423e8" -dependencies = [ - "backtrace", - "log", - "thiserror", - "winapi 0.3.9", - "windows 0.44.0", -] - -[[package]] -name = "gpu-descriptor" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" -dependencies = [ - "bitflags 2.4.1", - "gpu-descriptor-types", - "hashbrown 0.14.1", -] - -[[package]] -name = "gpu-descriptor-types" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" -dependencies = [ - "bitflags 2.4.1", -] - -[[package]] -name = "grid" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eec1c01eb1de97451ee0d60de7d81cf1e72aabefb021616027f3d1c3ec1c723c" - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand 0.8.5", - "rand_core 0.6.4", - "rand_xorshift 0.3.0", - "subtle", -] - -[[package]] -name = "guillotiere" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62d5865c036cb1393e23c50693df631d3f5d7bcca4c04fe4cc0fd592e74a782" -dependencies = [ - "euclid", - "svg_fmt", -] - -[[package]] -name = "h2" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" -dependencies = [ - "bytes 1.5.0", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 1.9.3", - "slab", - "tokio 1.33.0", - "tokio-util", - "tracing", -] - -[[package]] -name = "hamming" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" - -[[package]] -name = "hash-db" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03501f6e1a2a97f1618879aba3156f14ca2847faa530c4e28859638bd11483" - -[[package]] -name = "hashbrown" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" -dependencies = [ - "ahash 0.3.8", - "autocfg 1.1.0", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - -[[package]] -name = "hashbrown" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" -dependencies = [ - "ahash 0.8.3", - "allocator-api2", - "serde", -] - -[[package]] -name = "hassle-rs" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1397650ee315e8891a0df210707f0fc61771b0cc518c3023896064c5407cb3b0" -dependencies = [ - "bitflags 1.3.2", - "com-rs", - "libc", - "libloading 0.7.4", - "thiserror", - "widestring", - "winapi 0.3.9", -] - -[[package]] -name = "heap-map" -version = "0.1.0" -dependencies = [ - "malloc_size_of", - "malloc_size_of_derive", -] - -[[package]] -name = "heapsize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hexasphere" -version = "9.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb3df16a7bcb1b5bc092abd55e14f77ca70aea14445026e264586fc62889a10" -dependencies = [ - "constgebra", - "glam", -] - -[[package]] -name = "hexf-parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" - -[[package]] -name = "hibitset" -version = "0.6.0" -dependencies = [ - "atom", - "malloc_size_of", - "malloc_size_of_derive", - "rayon", -] - -[[package]] -name = "hkdf" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" -dependencies = [ - "digest 0.9.0", - "hmac 0.10.1", -] - -[[package]] -name = "hmac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" -dependencies = [ - "crypto-mac 0.10.1", - "digest 0.9.0", -] - -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac 0.11.1", - "digest 0.9.0", -] - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "hmac-sha256" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3688e69b38018fec1557254f64c8dc2cc8ec502890182f395dbb0aa997aa5735" - -[[package]] -name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "hostname" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" -dependencies = [ - "libc", - "match_cfg", - "winapi 0.3.9", -] - -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes 1.5.0", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes 1.5.0", - "http", - "pin-project-lite 0.2.13", -] - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "hyper" -version = "0.14.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" -dependencies = [ - "bytes 1.5.0", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite 0.2.13", - "socket2 0.4.9", - "tokio 1.33.0", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes 1.5.0", - "hyper", - "native-tls", - "tokio 1.33.0", - "tokio-native-tls", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "idna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "igd" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5bab3d4e7e5b7e564770440ee64b6ae9fd227434ea8f2845ed5b5859d7ca652" -dependencies = [ - "attohttpc", - "rand 0.7.3", - "url", - "xmltree", -] - -[[package]] -name = "image" -version = "0.24.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "num-rational 0.4.1", - "num-traits", - "png", -] - -[[package]] -name = "impl-codec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-rlp" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" -dependencies = [ - "rlp 0.4.6", -] - -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef5550a42e3740a0e71f909d4c861056a284060af885ae7aa6242820f920d9d" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg 1.1.0", - "hashbrown 0.12.3", -] - -[[package]] -name = "indexmap" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" -dependencies = [ - "equivalent", - "hashbrown 0.14.1", -] - -[[package]] -name = "inflections" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" - -[[package]] -name = "influx_db_client" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ef03268010ccf98c178eed83aa7377b7f6531f8ec8d43a256902c24cadac60" -dependencies = [ - "bytes 1.5.0", - "futures 0.3.28", - "reqwest", - "serde", - "serde_json", -] - -[[package]] -name = "inotify" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" -dependencies = [ - "bitflags 1.3.2", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" -dependencies = [ - "libc", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "io" -version = "0.1.0" -dependencies = [ - "crossbeam-channel 0.4.4", - "crossbeam-deque 0.7.4", - "fnv", - "lazy_static", - "log", - "metrics", - "mio 0.6.23", - "num_cpus", - "parking_lot 0.11.2", - "slab", - "time", - "timer", -] - -[[package]] -name = "io-kit-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2d4429acc1deff0fbdece0325b4997bdb02b2c245ab7023fd5deca0f6348de" -dependencies = [ - "core-foundation-sys", - "mach2", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "ipnet" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" - -[[package]] -name = "ipnetwork" -version = "0.12.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70783119ac90828aaba91eae39db32c6c1b8838deea3637e5238efa0130801ab" - -[[package]] -name = "itertools" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - -[[package]] -name = "jni" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" -dependencies = [ - "cesu8", - "combine", - "jni-sys", - "log", - "thiserror", - "walkdir", -] - -[[package]] -name = "jni" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "039022cdf4d7b1cf548d31f60ae783138e5fd42013f6271049d7df7afadef96c" -dependencies = [ - "cesu8", - "combine", - "jni-sys", - "log", - "thiserror", - "walkdir", -] - -[[package]] -name = "jni-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" - -[[package]] -name = "jobserver" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" -dependencies = [ - "libc", -] - -[[package]] -name = "journaldb" -version = "0.2.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ethereum-types 0.4.2", - "fastmap", - "hash-db", - "heapsize", - "keccak-hasher", - "kvdb 0.1.1", - "log", - "memory-db", - "parity-bytes", - "parking_lot 0.7.1", - "rlp 0.3.0", -] - -[[package]] -name = "js-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonrpc-core" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0745a6379e3edc893c84ec203589790774e4247420033e71a76d3ab4687991fa" -dependencies = [ - "futures 0.1.31", - "log", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "keccak-hash" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "253bbe643c32c816bf58fa5a88248fafedeebb139705ad17a62add3517854a86" -dependencies = [ - "ethereum-types 0.4.2", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "keccak-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f58a51ef3df9398cf2434bea8d4eb61fb748d0feb1571f87388579a120a4c8f" -dependencies = [ - "primitive-types", - "tiny-keccak 2.0.2", -] - -[[package]] -name = "keccak-hasher" -version = "0.1.1" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ethereum-types 0.4.2", - "hash-db", - "plain_hasher", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "khronos-egl" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3" -dependencies = [ - "libc", - "libloading 0.7.4", - "pkg-config", -] - -[[package]] -name = "kqueue" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" -dependencies = [ - "kqueue-sys", - "libc", -] - -[[package]] -name = "kqueue-sys" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" -dependencies = [ - "bitflags 1.3.2", - "libc", -] - -[[package]] -name = "ktx2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87d65e08a9ec02e409d27a0139eaa6b9756b4d81fe7cde71f6941a83730ce838" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "kvdb" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b2f251f01a7224426abdb2563707d856f7de995d821744fd8fa8e2874f69e3" -dependencies = [ - "elastic-array", - "parity-bytes", -] - -[[package]] -name = "kvdb" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03080afe6f42cd996da9f568d6add5d7fb5ee2ea7fb7802d2d2cbd836958fd87" -dependencies = [ - "parity-bytes", - "parity-util-mem", - "smallvec 1.11.1", -] - -[[package]] -name = "kvdb-memorydb" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "296c12309ed36cb74d59206406adbf1971c3baa56d5410efdb508d8f1c60a351" -dependencies = [ - "kvdb 0.1.1", - "parking_lot 0.9.0", -] - -[[package]] -name = "kvdb-rocksdb" -version = "0.1.6" -dependencies = [ - "cfx-types", - "fs-swap", - "kvdb 0.4.0", - "log", - "malloc_size_of", - "malloc_size_of_derive", - "num_cpus", - "parity-util-mem", - "parking_lot 0.11.2", - "regex", - "rocksdb", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin", -] - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - -[[package]] -name = "len-caching-lock" -version = "0.1.1" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "parking_lot 0.7.1", -] - -[[package]] -name = "lewton" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777b48df9aaab155475a83a7df3070395ea1ac6902f5cd062b8f2b028075c030" -dependencies = [ - "byteorder", - "ogg", - "tinyvec", -] - -[[package]] -name = "libc" -version = "0.2.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" - -[[package]] -name = "libflate" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ff4ae71b685bbad2f2f391fe74f6b7659a34871c08b210fdc039e43bee07d18" -dependencies = [ - "adler32", - "crc32fast", - "libflate_lz77", -] - -[[package]] -name = "libflate_lz77" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf" -dependencies = [ - "rle-decode-fast", -] - -[[package]] -name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi 0.3.9", -] - -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if 1.0.0", - "winapi 0.3.9", -] - -[[package]] -name = "libloading" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - -[[package]] -name = "librocksdb_sys" -version = "0.1.0" -source = "git+https://github.com/Conflux-Chain/rust-rocksdb.git?rev=a1ce5bd3322a7b732dfb300c2571dc4d99f1edae#a1ce5bd3322a7b732dfb300c2571dc4d99f1edae" -dependencies = [ - "bindgen 0.64.0", - "bzip2-sys", - "cc", - "cmake", - "libc", - "libtitan_sys", - "libz-sys", - "lz4-sys", - "snappy-sys", - "zstd-sys", -] - -[[package]] -name = "libtitan_sys" -version = "0.0.1" -source = "git+https://github.com/Conflux-Chain/rust-rocksdb.git?rev=a1ce5bd3322a7b732dfb300c2571dc4d99f1edae#a1ce5bd3322a7b732dfb300c2571dc4d99f1edae" -dependencies = [ - "bzip2-sys", - "cc", - "cmake", - "libc", - "libz-sys", - "lz4-sys", - "path-slash", - "snappy-sys", - "zstd-sys", -] - -[[package]] -name = "libudev-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" -dependencies = [ - "libc", - "pkg-config", -] - -[[package]] -name = "libz-sys" -version = "1.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "link-cut-tree" -version = "0.1.0" -dependencies = [ - "cfx-types", - "malloc_size_of", - "malloc_size_of_derive", - "parking_lot 0.11.2", - "rand 0.7.3", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linux-raw-sys" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" - -[[package]] -name = "lock_api" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" -dependencies = [ - "owning_ref", - "scopeguard 0.3.3", -] - -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard 1.2.0", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg 1.1.0", - "scopeguard 1.2.0", -] - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" -dependencies = [ - "serde", -] - -[[package]] -name = "log-mdc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" - -[[package]] -name = "log4rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36ca1786d9e79b8193a68d480a0907b612f109537115c6ff655a3a1967533fd" -dependencies = [ - "anyhow", - "arc-swap", - "chrono", - "derivative", - "flate2", - "fnv", - "humantime 2.1.0", - "libc", - "log", - "log-mdc", - "parking_lot 0.12.1", - "serde", - "serde-value", - "serde_json", - "serde_yaml", - "thiserror", - "thread-id", - "typemap-ors", - "winapi 0.3.9", -] - -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "lru_time_cache" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab44e08e5b5110188be64dc8f0865635206ad7386fe672903bef195df3cc8960" - -[[package]] -name = "lz4-sys" -version = "1.8.3" -source = "git+https://github.com/busyjay/lz4-rs.git?branch=adjust-build#5a8afe4010c67899fc7af876a58d67fd6269bf81" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "mach2" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0d1830bcd151a6fc4aea1369af235b36c1528fe976b8ff678683c9995eade8" -dependencies = [ - "libc", -] - -[[package]] -name = "macros" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" - -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - -[[package]] -name = "malloc_size_of" -version = "0.0.1" -dependencies = [ - "cfg-if 0.1.10", - "cfx-types", - "hashbrown 0.7.2", - "parking_lot 0.11.2", - "slab", - "smallvec 1.11.1", - "winapi 0.3.9", -] - -[[package]] -name = "malloc_size_of_derive" -version = "0.1.1" -dependencies = [ - "proc-macro2 1.0.69", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "match_cfg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memmap" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "memoffset" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" - -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "memory-cache" -version = "0.1.0" -dependencies = [ - "lru-cache", - "malloc_size_of", -] - -[[package]] -name = "memory-cache" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "heapsize", - "lru-cache", -] - -[[package]] -name = "memory-db" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94da53143d45f6bad3753f532e56ad57a6a26c0ca6881794583310c7cb4c885f" -dependencies = [ - "hash-db", - "heapsize", -] - -[[package]] -name = "memory_units" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" - -[[package]] -name = "memzero" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" - -[[package]] -name = "metal" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de11355d1f6781482d027a3b4d4de7825dcedb197bf573e0596d00008402d060" -dependencies = [ - "bitflags 1.3.2", - "block", - "core-graphics-types", - "foreign-types", - "log", - "objc", -] - -[[package]] -name = "metrics" -version = "0.1.0" -dependencies = [ - "futures 0.3.28", - "influx_db_client", - "lazy_static", - "log", - "log4rs", - "parking_lot 0.11.2", - "rand 0.7.3", - "time", - "timer", - "tokio 1.33.0", -] - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", - "simd-adler32", -] - -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.2", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "mio" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" -dependencies = [ - "libc", - "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", -] - -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio 0.6.23", - "miow 0.3.7", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio 0.6.23", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "mirai-annotations" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" - -[[package]] -name = "move-core-types" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "cfx-types", - "hex", - "mirai-annotations", - "once_cell", - "rand 0.8.5", - "ref-cast", - "serde", - "serde_bytes", -] - -[[package]] -name = "naga" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbcc2e0513220fd2b598e6068608d4462db20322c0e77e47f6f488dfcfc279cb" -dependencies = [ - "bit-set 0.5.3", - "bitflags 1.3.2", - "codespan-reporting", - "hexf-parse", - "indexmap 1.9.3", - "log", - "num-traits", - "pp-rs", - "rustc-hash", - "spirv", - "termcolor", - "thiserror", - "unicode-xid 0.2.4", -] - -[[package]] -name = "naga_oil" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be942a5c21c58b9b0bf4d9b99db3634ddb7a916f8e1d1d0b71820cc4150e56b" -dependencies = [ - "bit-set 0.5.3", - "codespan-reporting", - "data-encoding", - "indexmap 1.9.3", - "naga", - "once_cell", - "regex", - "regex-syntax 0.6.29", - "rustc-hash", - "thiserror", - "tracing", - "unicode-ident", -] - -[[package]] -name = "nan-preserving-float" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "natpmp" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d85b74917d95eab8b26ab6fe28e21d3fede3a614411ca4d3b01265c05bf86a12" -dependencies = [ - "cc", -] - -[[package]] -name = "ndk" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" -dependencies = [ - "bitflags 1.3.2", - "jni-sys", - "ndk-sys", - "num_enum 0.5.11", - "raw-window-handle", - "thiserror", -] - -[[package]] -name = "ndk-context" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" - -[[package]] -name = "ndk-sys" -version = "0.4.1+23.1.7779620" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" -dependencies = [ - "jni-sys", -] - -[[package]] -name = "net2" -version = "0.2.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "network" -version = "0.1.0" -dependencies = [ - "byte-unit", - "bytes 0.4.12", - "cfx-addr", - "cfx-bytes", - "cfx-types", - "cfxkey", - "diem-crypto", - "diem-types", - "enum-map", - "enum-map-derive", - "error-chain", - "igd", - "io", - "ipnetwork", - "keccak-hash 0.5.1", - "lazy_static", - "libc", - "log", - "malloc_size_of", - "metrics", - "mio 0.6.23", - "natpmp", - "parity-path", - "parking_lot 0.11.2", - "priority-send-queue", - "rand 0.7.3", - "rlp 0.4.6", - "rlp_derive 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", - "serde", - "serde_derive", - "serde_json", - "slab", - "strum 0.11.0", - "strum_macros 0.11.0", - "throttling", -] - -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", -] - -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "notify" -version = "6.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" -dependencies = [ - "bitflags 2.4.1", - "crossbeam-channel 0.5.8", - "filetime", - "fsevent-sys", - "inotify", - "kqueue", - "libc", - "log", - "mio 0.8.8", - "walkdir", - "windows-sys 0.48.0", -] - -[[package]] -name = "ntapi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi 0.3.9", -] - -[[package]] -name = "num" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" -dependencies = [ - "num-bigint 0.1.44", - "num-integer", - "num-iter", - "num-traits", -] - -[[package]] -name = "num" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" -dependencies = [ - "num-bigint 0.2.6", - "num-complex", - "num-integer", - "num-iter", - "num-rational 0.2.4", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63899ad0da84ce718c14936262a41cee2c79c981fc0a0e7c7beb47d5a07e8c1" -dependencies = [ - "num-integer", - "num-traits", - "rand 0.4.6", - "rustc-serialize", -] - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg 1.1.0", - "num-traits", -] - -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg 1.1.0", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg 1.1.0", - "num-bigint 0.2.6", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "num-variants" -version = "0.1.0" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.3", - "libc", -] - -[[package]] -name = "num_enum" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" -dependencies = [ - "num_enum_derive 0.5.11", -] - -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive 0.6.1", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "num_enum_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", - "objc_exception", -] - -[[package]] -name = "objc-sys" -version = "0.2.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" - -[[package]] -name = "objc2" -version = "0.3.0-beta.3.patch-leaks.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468" -dependencies = [ - "block2", - "objc-sys", - "objc2-encode", -] - -[[package]] -name = "objc2-encode" -version = "2.0.0-pre.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512" -dependencies = [ - "objc-sys", -] - -[[package]] -name = "objc_exception" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" -dependencies = [ - "cc", -] - -[[package]] -name = "object" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" -dependencies = [ - "memchr", -] - -[[package]] -name = "oboe" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8868cc237ee02e2d9618539a23a8d228b9bb3fc2e7a5b11eed3831de77c395d0" -dependencies = [ - "jni 0.20.0", - "ndk", - "ndk-context", - "num-derive", - "num-traits", - "oboe-sys", -] - -[[package]] -name = "oboe-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f44155e7fb718d3cfddcf70690b2b51ac4412f347cd9e4fbe511abe9cd7b5f2" -dependencies = [ - "cc", -] - -[[package]] -name = "ogg" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6951b4e8bf21c8193da321bcce9c9dd2e13c858fe078bf9054a288b419ae5d6e" -dependencies = [ - "byteorder", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl" -version = "0.10.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" -dependencies = [ - "bitflags 2.4.1", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.93" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "orbclient" -version = "0.3.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8378ac0dfbd4e7895f2d2c1f1345cab3836910baf3a300b000d04250f0c8428f" -dependencies = [ - "redox_syscall 0.3.5", -] - -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", -] - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "owned_ttf_parser" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "706de7e2214113d63a8238d1910463cfce781129a6f263d13fdb09ff64355ba4" -dependencies = [ - "ttf-parser", -] - -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] - -[[package]] -name = "pairing" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" -dependencies = [ - "group", -] - -[[package]] -name = "parity-bytes" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b56e3a2420138bdb970f84dfb9c774aea80fa0e7371549eedec0d80c209c67" - -[[package]] -name = "parity-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b9db194dfbcfe3b398d63d765437a5c7232d59906e203055f0e993f6458ff1" -dependencies = [ - "quick-error", - "ring", - "rust-crypto", - "tiny-keccak 1.5.0", -] - -[[package]] -name = "parity-crypto" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b92ea9ddac0d6e1db7c49991e7d397d34a9fd814b4c93cda53788e8eef94e35" -dependencies = [ - "aes 0.6.0", - "aes-ctr", - "block-modes 0.7.0", - "digest 0.9.0", - "hmac 0.10.1", - "pbkdf2 0.7.5", - "ripemd160", - "scrypt 0.5.0", - "sha2 0.9.9", - "subtle", - "tiny-keccak 2.0.2", - "zeroize", -] - -[[package]] -name = "parity-machine" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ethereum-types 0.4.2", -] - -[[package]] -name = "parity-path" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f66a327a200fe67c16f1d0acab2f74a2ec67c41d6202a2a98a7378df653d848d" -dependencies = [ - "home", -] - -[[package]] -name = "parity-runtime" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "futures 0.1.31", - "tokio 0.1.22", -] - -[[package]] -name = "parity-scale-codec" -version = "1.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b26b16c7687c3075982af47719e481815df30bc544f7a6690763a25ca16e9d" -dependencies = [ - "arrayvec 0.5.2", - "bitvec 0.17.4", - "byte-slice-cast 0.3.5", - "serde", -] - -[[package]] -name = "parity-secp256k1" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fca4f82fccae37e8bbdaeb949a4a218a1bbc485d11598f193d2a908042e5fc1" -dependencies = [ - "arrayvec 0.5.2", - "cc", - "cfg-if 0.1.10", - "rand 0.7.3", -] - -[[package]] -name = "parity-snappy" -version = "0.1.0" -dependencies = [ - "libc", - "snappy-sys", -] - -[[package]] -name = "parity-util-mem" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9344bc978467339b9ae688f9dcf279d1aaa0ccfc88e9a780c729b765a82d57d5" -dependencies = [ - "cfg-if 0.1.10", - "impl-trait-for-tuples", - "parity-util-mem-derive", - "winapi 0.3.9", -] - -[[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2 1.0.69", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "parity-wasm" -version = "0.31.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" -dependencies = [ - "byteorder", -] - -[[package]] -name = "parity-wordlist" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f45ab1896c154f80a23f22aa81134b881e18b8fb7ff106abe67ae53a161d54a0" -dependencies = [ - "lazy_static", - "rand 0.7.3", -] - -[[package]] -name = "parking" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" - -[[package]] -name = "parking_lot" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.3.1", -] - -[[package]] -name = "parking_lot" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" -dependencies = [ - "lock_api 0.1.5", - "parking_lot_core 0.4.0", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.3", - "rustc_version", -] - -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api 0.4.11", - "parking_lot_core 0.8.6", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api 0.4.11", - "parking_lot_core 0.9.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" -dependencies = [ - "libc", - "rand 0.5.6", - "rustc_version", - "smallvec 0.6.14", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" -dependencies = [ - "libc", - "rand 0.6.5", - "rustc_version", - "smallvec 0.6.14", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66b810a62be75176a80873726630147a5ca780cd33921e0b5709033e66b0a" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "rustc_version", - "smallvec 0.6.14", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if 1.0.0", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec 1.11.1", - "winapi 0.3.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall 0.4.1", - "smallvec 1.11.1", - "windows-targets 0.48.5", -] - -[[package]] -name = "password-hash" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54986aa4bfc9b98c6a5f40184223658d187159d7b3c6af33f2b2aa25ae1db0fa" -dependencies = [ - "base64ct", - "rand_core 0.6.4", -] - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "path-absolutize" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" -dependencies = [ - "path-dedot", -] - -[[package]] -name = "path-dedot" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" -dependencies = [ - "once_cell", -] - -[[package]] -name = "path-slash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "498a099351efa4becc6a19c72aa9270598e8fd274ca47052e37455241c88b696" - -[[package]] -name = "patricia-trie-ethereum" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "elastic-array", - "ethereum-types 0.4.2", - "hash-db", - "keccak-hasher", - "parity-bytes", - "rlp 0.3.0", - "trie-db", -] - -[[package]] -name = "pbkdf2" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3b8c0d71734018084da0c0354193a5edfb81b20d2d57a92c5b154aefc554a4a" -dependencies = [ - "crypto-mac 0.10.1", -] - -[[package]] -name = "pbkdf2" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf916dd32dd26297907890d99dc2740e33f6bd9073965af4ccff2967962f5508" -dependencies = [ - "base64ct", - "crypto-mac 0.10.1", - "hmac 0.10.1", - "password-hash", - "sha2 0.9.9", -] - -[[package]] -name = "pbkdf2" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739" -dependencies = [ - "crypto-mac 0.11.1", -] - -[[package]] -name = "pbkdf2" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - -[[package]] -name = "petgraph" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" -dependencies = [ - "fixedbitset", - "indexmap 2.0.2", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pipe-logger-lib" -version = "1.1.13" -source = "git+https://github.com/aleksuss/pipe-logger-lib.git?rev=3ff3550fc7e46d6e530daf1a47471c6628baa43d#3ff3550fc7e46d6e530daf1a47471c6628baa43d" -dependencies = [ - "chrono", - "libflate", - "path-absolutize", - "regex", -] - -[[package]] -name = "pkcs5" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5423c5ee112e07717eb3634de80e5d34f0019dd65f3eead74028d9c579ce7dd4" -dependencies = [ - "aes 0.7.5", - "block-modes 0.8.1", - "der", - "hmac 0.11.0", - "pbkdf2 0.9.0", - "scrypt 0.8.1", - "sha2 0.9.9", - "spki", -] - -[[package]] -name = "pkcs8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" -dependencies = [ - "der", - "pkcs5", - "rand_core 0.6.4", - "spki", - "zeroize", -] - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - -[[package]] -name = "plain_hasher" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e19e6491bdde87c2c43d70f4c194bc8a758f2eb732df00f61e43f7362e3b4cc" -dependencies = [ - "crunchy 0.2.2", -] - -[[package]] -name = "png" -version = "0.17.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" -dependencies = [ - "bitflags 1.3.2", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide", -] - -[[package]] -name = "polyval" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" -dependencies = [ - "cpuid-bool", - "opaque-debug", - "universal-hash", -] - -[[package]] -name = "pos-ledger-db" -version = "0.1.0" -dependencies = [ - "accumulator", - "anyhow", - "arc-swap", - "bcs", - "byteorder", - "consensus-types", - "diem-config", - "diem-crypto", - "diem-infallible", - "diem-jellyfish-merkle", - "diem-logger", - "diem-metrics", - "diem-types", - "executor-types", - "itertools 0.10.5", - "num-derive", - "num-traits", - "num-variants", - "once_cell", - "schemadb", - "serde", - "storage-interface", - "thiserror", -] - -[[package]] -name = "pow-types" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-trait", - "cfx-types", - "serde", -] - -[[package]] -name = "pp-rs" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb458bb7f6e250e6eb79d5026badc10a3ebb8f9a15d1fff0f13d17c71f4d6dee" -dependencies = [ - "unicode-xid 0.2.4", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "primal" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e31b86efadeaeb1235452171a66689682783149a6249ff334a2c5d8218d00a4" -dependencies = [ - "primal-check", - "primal-estimate", - "primal-sieve", -] - -[[package]] -name = "primal-bit" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686a64e2f50194c64942992af5799e6b6e8775b8f88c607d72ed0a2fd58b9b21" -dependencies = [ - "hamming", -] - -[[package]] -name = "primal-check" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e65f96c0a171f887198c274392c99a116ef65aa7f53f3b6d4902f493965c2d1" -dependencies = [ - "num-integer", -] - -[[package]] -name = "primal-estimate" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ea4531dde757b56906493c8604641da14607bf9cdaa80fb9c9cabd2429f8d5" - -[[package]] -name = "primal-sieve" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2d6ed369bb4b0273aeeb43f07c105c0117717cbae827b20719438eb2eb798c" -dependencies = [ - "hamming", - "primal-bit", - "primal-estimate", - "smallvec 0.6.14", -] - -[[package]] -name = "primitive-types" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" -dependencies = [ - "fixed-hash 0.6.1", - "impl-codec", - "impl-rlp", - "impl-serde", - "uint 0.8.5", -] - -[[package]] -name = "primitives" -version = "0.2.0" -dependencies = [ - "byteorder", - "cfx-bytes", - "cfx-types", - "cfxkey", - "fixed-hash 0.5.2", - "keccak-hash 0.5.1", - "lazy_static", - "log", - "malloc_size_of", - "once_cell", - "rand 0.7.3", - "rlp 0.4.6", - "rlp_derive 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", - "serde", - "serde_derive", - "siphasher 0.3.11", - "unexpected 0.1.0 (git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1)", -] - -[[package]] -name = "priority-send-queue" -version = "0.1.0" - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "profiling" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f89dff0959d98c9758c88826cc002e2c3d0b9dfac4139711d1f30de442f1139b" - -[[package]] -name = "prometheus" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5567486d5778e2c6455b1b90ff1c558f29e751fc018130fa182e15828e728af1" -dependencies = [ - "cfg-if 0.1.10", - "fnv", - "lazy_static", - "quick-error", - "spin", -] - -[[package]] -name = "prometheus" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5986aa8d62380092d2f50f8b1cdba9cb9b6731ffd4b25b51fd126b6c3e05b99c" -dependencies = [ - "cfg-if 1.0.0", - "fnv", - "lazy_static", - "memchr", - "parking_lot 0.11.2", - "thiserror", -] - -[[package]] -name = "proxy" -version = "0.1.0" -dependencies = [ - "ipnet", -] - -[[package]] -name = "pwasm-utils" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb0dcbddbb600f47a7098d33762a00552c671992171637f5bb310b37fe1f0e4" -dependencies = [ - "byteorder", - "log", - "parity-wasm", -] - -[[package]] -name = "qstring" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d464fae65fff2680baf48019211ce37aaec0c78e9264c84a3e484717f965104e" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2 1.0.69", -] - -[[package]] -name = "radium" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "radsort" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17fd96390ed3feda12e1dfe2645ed587e0bea749e319333f104a33ff62f77a0b" - -[[package]] -name = "rand" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -dependencies = [ - "libc", - "rand 0.4.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift 0.1.1", - "winapi 0.3.9", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.10", -] - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_xorshift" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_xorshift" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" -dependencies = [ - "rand_core 0.6.4", -] - -[[package]] -name = "random-crash" -version = "1.0.0" -dependencies = [ - "lazy_static", - "log", - "parking_lot 0.11.2", - "rand 0.7.3", -] - -[[package]] -name = "range-alloc" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" - -[[package]] -name = "raw-window-handle" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" - -[[package]] -name = "rayon" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" -dependencies = [ - "crossbeam-deque 0.8.3", - "crossbeam-utils 0.8.16", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rectangle-pack" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d463f2884048e7153449a55166f91028d5b0ea53c79377099ce4e8cf0cf9bb" - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "reexport-proc-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fd6195683d528242d8b017810909f8aaf91f111fdc4dbe8b10e4dd50e0c7f4" - -[[package]] -name = "ref-cast" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.3", - "regex-syntax 0.8.2", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.2", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "renderdoc-sys" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" - -[[package]] -name = "reqwest" -version = "0.11.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" -dependencies = [ - "base64 0.21.4", - "bytes 1.5.0", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-tls", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite 0.2.13", - "serde", - "serde_json", - "serde_urlencoded", - "system-configuration", - "tokio 1.33.0", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "ring" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" -dependencies = [ - "cc", - "lazy_static", - "libc", - "spin", - "untrusted", - "winapi 0.3.9", -] - -[[package]] -name = "ripemd160" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eca4ecc81b7f313189bf73ce724400a07da2a6dac19588b03c8bd76a2dcc251" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "rle-decode-fast" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" - -[[package]] -name = "rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d1effe9845d54f90e7be8420ee49e5c94623140b97ee4bc6fb5bfddb745720" -dependencies = [ - "byteorder", - "ethereum-types 0.4.2", - "rustc-hex 2.1.0", -] - -[[package]] -name = "rlp" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73" -dependencies = [ - "rustc-hex 2.1.0", -] - -[[package]] -name = "rlp_compress" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "elastic-array", - "lazy_static", - "rlp 0.3.0", -] - -[[package]] -name = "rlp_derive" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "rlp_derive" -version = "0.1.0" -source = "git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1#1597a9cab02343eb2322ca0ac58d39b64e3f42d1" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "rocksdb" -version = "0.3.0" -source = "git+https://github.com/Conflux-Chain/rust-rocksdb.git?rev=a1ce5bd3322a7b732dfb300c2571dc4d99f1edae#a1ce5bd3322a7b732dfb300c2571dc4d99f1edae" -dependencies = [ - "libc", - "librocksdb_sys", -] - -[[package]] -name = "rodio" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79a48a12b54a6db15f566f5edfcd498eafa07ed98defdb3660e28ab8b0231d35" -dependencies = [ - "cpal", - "lewton", -] - -[[package]] -name = "ron" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" -dependencies = [ - "base64 0.21.4", - "bitflags 2.4.1", - "serde", - "serde_derive", -] - -[[package]] -name = "rust-crypto" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" -dependencies = [ - "gcc", - "libc", - "rand 0.3.23", - "rustc-serialize", - "time", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc-hex" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "rustix" -version = "0.38.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] - -[[package]] -name = "ruzstd" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3ffab8f9715a0d455df4bbb9d21e91135aab3cd3ca187af0cd0c3c3f868fdc" -dependencies = [ - "byteorder", - "thiserror-core", - "twox-hash", -] - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "safety-rules" -version = "0.1.0" -dependencies = [ - "bcs", - "consensus-types", - "crash-handler", - "diem-config", - "diem-crypto", - "diem-global-constants", - "diem-infallible", - "diem-logger", - "diem-secure-net", - "diem-secure-push-metrics", - "diem-secure-storage", - "diem-temppath", - "diem-types", - "diem-vault-client", - "log", - "once_cell", - "rand 0.8.5", - "rand_core 0.6.4", - "serde", - "thiserror", -] - -[[package]] -name = "salsa20" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "399f290ffc409596022fce5ea5d4138184be4784f2b28c62c59f0d8389059a15" -dependencies = [ - "cipher 0.2.5", -] - -[[package]] -name = "salsa20" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0fbb5f676da676c260ba276a8f43a8dc67cf02d1438423aeb1c677a7212686" -dependencies = [ - "cipher 0.3.0", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "schemadb" -version = "0.1.0" -dependencies = [ - "anyhow", - "diem-config", - "diem-logger", - "diem-metrics", - "once_cell", - "rocksdb", -] - -[[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "scratchpad" -version = "0.1.0" -dependencies = [ - "arc-swap", - "diem-crypto", - "diem-infallible", - "diem-types", - "itertools 0.10.5", -] - -[[package]] -name = "scrypt" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da492dab03f925d977776a0b7233d7b934d6dc2b94faead48928e2e9bacedb9" -dependencies = [ - "base64 0.13.1", - "hmac 0.10.1", - "pbkdf2 0.6.0", - "rand 0.7.3", - "rand_core 0.5.1", - "salsa20 0.7.2", - "sha2 0.9.9", - "subtle", -] - -[[package]] -name = "scrypt" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73d6d7c6311ebdbd9184ad6c4447b2f36337e327bda107d3ba9e3c374f9d325" -dependencies = [ - "hmac 0.12.1", - "pbkdf2 0.10.1", - "salsa20 0.9.0", - "sha2 0.10.8", -] - -[[package]] -name = "secret-store" -version = "0.1.0" -dependencies = [ - "cfx-types", - "cfxkey", - "malloc_size_of", - "malloc_size_of_derive", - "parking_lot 0.11.2", - "rand 0.7.3", - "rlp 0.4.6", -] - -[[package]] -name = "security-framework" -version = "2.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.189" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-name" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12c47087018ec281d1cdab673d36aea22d816b54d498264029c05d5fa1910da6" -dependencies = [ - "serde", - "thiserror", -] - -[[package]] -name = "serde-value" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" -dependencies = [ - "ordered-float", - "serde", -] - -[[package]] -name = "serde_bytes" -version = "0.11.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.189" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "serde_json" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_yaml" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" -dependencies = [ - "indexmap 1.9.3", - "ryu", - "serde", - "yaml-rust", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha3-macro" -version = "0.1.0" -dependencies = [ - "keccak-hash 0.5.1", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "shlex" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" - -[[package]] -name = "short-hex-str" -version = "0.1.0" -dependencies = [ - "mirai-annotations", - "serde", - "static_assertions", - "thiserror", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" - -[[package]] -name = "simd-adler32" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" - -[[package]] -name = "siphasher" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833011ca526bd88f16778d32c699d325a9ad302fa06381cd66f7be63351d3f6d" - -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "slotmap" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" -dependencies = [ - "version_check", -] - -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "smallvec" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" -dependencies = [ - "serde", -] - -[[package]] -name = "smart-default" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "smol_str" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" -dependencies = [ - "serde", -] - -[[package]] -name = "snappy-sys" -version = "0.1.0" -source = "git+https://github.com/busyjay/rust-snappy?branch=static-link#8c12738bad811397600455d6982aff754ea2ac44" -dependencies = [ - "cmake", - "libc", - "pkg-config", -] - -[[package]] -name = "socket2" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "socket2" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "solidity-abi" -version = "0.1.0" -dependencies = [ - "cfx-types", - "keccak-hash 0.5.1", - "solidity-abi-derive", -] - -[[package]] -name = "solidity-abi-derive" -version = "0.1.0" -dependencies = [ - "proc-macro-crate", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spirv" -version = "0.2.0+1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" -dependencies = [ - "bitflags 1.3.2", - "num-traits", -] - -[[package]] -name = "spki" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" -dependencies = [ - "der", -] - -[[package]] -name = "sqlite" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35f759dc2e373e1edd0a27da87aa9136416360c5077a23643fcd6fcdc9cb9e31" -dependencies = [ - "libc", - "sqlite3-sys", -] - -[[package]] -name = "sqlite3-src" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8bb25e66d026488228a97e0ad21e3d15ec5998dcd9ad73c97cc277c56a6b314" -dependencies = [ - "cc", - "pkg-config", -] - -[[package]] -name = "sqlite3-sys" -version = "0.12.0" -source = "git+https://github.com/Conflux-Chain/sqlite3-sys.git?rev=1de8e5998f7c2d919336660b8ef4e8f52ac43844#1de8e5998f7c2d919336660b8ef4e8f52ac43844" -dependencies = [ - "libc", - "sqlite3-src", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "stats" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "log", -] - -[[package]] -name = "storage-interface" -version = "0.1.0" -dependencies = [ - "anyhow", - "bcs", - "diem-crypto", - "diem-secure-net", - "diem-state-view", - "diem-types", - "itertools 0.10.5", - "move-core-types", - "parking_lot 0.11.2", - "scratchpad", - "serde", - "thiserror", -] - -[[package]] -name = "storage_bench" -version = "0.1.0" -dependencies = [ - "base64ct", - "bevy", - "cfx-internal-common", - "cfx-statedb", - "cfx-storage", - "cfx-types", - "cfxcore", - "clap", - "common-types", - "db", - "env_logger", - "error-chain", - "ethcore", - "ethereum-types 0.4.2", - "ethjson", - "ethkey", - "heapsize", - "kvdb 0.4.0", - "lazy_static", - "log", - "parking_lot 0.11.2", - "primitives", - "rlp 0.3.0", - "serde_json", -] - -[[package]] -name = "strfmt" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b278b244ef7aa5852b277f52dd0c6cac3a109919e1f6d699adde63251227a30f" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "strum" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6c3a2071519ab6a48f465808c4c1ffdd00dfc8e93111d02b4fc5abab177676e" - -[[package]] -name = "strum" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c" - -[[package]] -name = "strum_macros" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8baacebd7b7c9b864d83a6ba7a246232983e277b86fa5cdec77f565715a4b136" -dependencies = [ - "heck", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "strum_macros" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" -dependencies = [ - "heck", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "subscription-service" -version = "0.1.0" -dependencies = [ - "anyhow", - "channel", - "diem-types", -] - -[[package]] -name = "substrate-bn" -version = "0.6.0" -source = "git+https://github.com/paritytech/bn?rev=63f8c587356a67b33c7396af98e065b66fca5dda#63f8c587356a67b33c7396af98e065b66fca5dda" -dependencies = [ - "byteorder", - "crunchy 0.2.2", - "lazy_static", - "rand 0.8.5", - "rustc-hex 2.1.0", -] - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "svg_fmt" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2" - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", - "unicode-xid 0.2.4", -] - -[[package]] -name = "sysinfo" -version = "0.29.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5" -dependencies = [ - "cfg-if 1.0.0", - "core-foundation-sys", - "libc", - "ntapi", - "once_cell", - "winapi 0.3.9", -] - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "taffy" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c488aa2bf4bb0cafed312e0876b79a591e3cfa47391f842b7198f9a56547561b" -dependencies = [ - "arrayvec 0.7.4", - "grid", - "num-traits", - "slotmap", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand 0.4.6", - "remove_dir_all", -] - -[[package]] -name = "tempfile" -version = "3.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" -dependencies = [ - "cfg-if 1.0.0", - "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix", - "windows-sys 0.48.0", -] - -[[package]] -name = "termcolor" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-core" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d97345f6437bb2004cd58819d8a9ef8e36cdd7661c2abc4bbde0a7c40d9f497" -dependencies = [ - "thiserror-core-impl", -] - -[[package]] -name = "thiserror-core-impl" -version = "1.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10ac1c5050e43014d16b2f94d0d2ce79e65ffdd8b38d8048f9c8f6a8a6da62ac" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "thread-id" -version = "4.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b" -dependencies = [ - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if 1.0.0", - "once_cell", -] - -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "throttling" -version = "0.1.0" -dependencies = [ - "malloc_size_of", - "malloc_size_of_derive", - "parking_lot 0.11.2", - "toml", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", -] - -[[package]] -name = "timer" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d42176308937165701f50638db1c31586f183f1aab416268216577aec7306b" -dependencies = [ - "chrono", -] - -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy 0.2.2", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy 0.2.2", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "mio 0.6.23", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", -] - -[[package]] -name = "tokio" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" -dependencies = [ - "bytes 0.5.6", - "fnv", - "futures-core", - "iovec", - "lazy_static", - "libc", - "memchr", - "mio 0.6.23", - "mio-named-pipes", - "mio-uds", - "num_cpus", - "pin-project-lite 0.1.12", - "signal-hook-registry", - "slab", - "tokio-macros 0.2.6", - "winapi 0.3.9", -] - -[[package]] -name = "tokio" -version = "1.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" -dependencies = [ - "backtrace", - "bytes 1.5.0", - "libc", - "mio 0.8.8", - "num_cpus", - "parking_lot 0.12.1", - "pin-project-lite 0.2.13", - "signal-hook-registry", - "socket2 0.5.4", - "tokio-macros 2.1.0", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "tokio-io", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.31", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.31", -] - -[[package]] -name = "tokio-fs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" -dependencies = [ - "futures 0.1.31", - "tokio-io", - "tokio-threadpool", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "log", -] - -[[package]] -name = "tokio-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "tokio-macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio 1.33.0", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.31", - "lazy_static", - "log", - "mio 0.6.23", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite 0.2.13", - "tokio 1.33.0", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures 0.1.31", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "iovec", - "mio 0.6.23", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque 0.7.4", - "crossbeam-queue", - "crossbeam-utils 0.7.2", - "futures 0.1.31", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.31", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-udp" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "log", - "mio 0.6.23", - "tokio-codec", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-uds" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "iovec", - "libc", - "log", - "mio 0.6.23", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-util" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" -dependencies = [ - "bytes 1.5.0", - "futures-core", - "futures-sink", - "pin-project-lite 0.2.13", - "tokio 1.33.0", - "tracing", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.0.2", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "trace-time" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1e75297b57b61495169dd40dd86e0ab52bfc7cdba570f59be5683709c9d480" -dependencies = [ - "log", -] - -[[package]] -name = "tracing" -version = "0.1.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9" -dependencies = [ - "pin-project-lite 0.2.13", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec 1.11.1", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "tracing-wasm" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07" -dependencies = [ - "tracing", - "tracing-subscriber", - "wasm-bindgen", -] - -[[package]] -name = "transaction-pool" -version = "1.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5866e5126b14358f1d7af4bf51a0be677a363799b90e655edcec8254edef1d2" -dependencies = [ - "error-chain", - "log", - "smallvec 0.6.14", - "trace-time", -] - -[[package]] -name = "treap-map" -version = "0.1.0" -dependencies = [ - "malloc_size_of", - "primitives", - "rand 0.7.3", - "rand_xorshift 0.2.0", -] - -[[package]] -name = "trie-db" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7319e28ca295f27359d944a682f7f65b419158bf1590c92cadc0000258d788" -dependencies = [ - "elastic-array", - "hash-db", - "log", - "rand 0.6.5", -] - -[[package]] -name = "triehash" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d26efb4ddf87870fc08dc9a6580dc3061be350d7b9d0eb30aef1c8b4227aa46" -dependencies = [ - "hash-db", - "rlp 0.3.0", -] - -[[package]] -name = "triehash-ethereum" -version = "0.2.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "ethereum-types 0.4.2", - "keccak-hasher", - "triehash", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "ttf-parser" -version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49d64318d8311fc2668e48b63969f4343e0a85c4a109aa8460d6672e364b8bd1" - -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if 1.0.0", - "static_assertions", -] - -[[package]] -name = "typemap-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a68c24b707f02dd18f1e4ccceb9d49f2058c2fb86384ef9972592904d7a28867" -dependencies = [ - "unsafe-any-ors", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "uint" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "754ba11732b9161b94c41798e5197e5e75388d012f760c42adb5000353e98646" -dependencies = [ - "byteorder", - "crunchy 0.1.6", - "heapsize", - "rustc-hex 2.1.0", -] - -[[package]] -name = "uint" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" -dependencies = [ - "byteorder", - "crunchy 0.2.2", - "rustc-hex 2.1.0", - "static_assertions", -] - -[[package]] -name = "unexpected" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" - -[[package]] -name = "unexpected" -version = "0.1.0" -source = "git+https://github.com/Conflux-Chain/conflux-parity-deps.git?rev=1597a9cab02343eb2322ca0ac58d39b64e3f42d1#1597a9cab02343eb2322ca0ac58d39b64e3f42d1" - -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "unroll" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad948c1cb799b1a70f836077721a92a35ac177d4daddf4c20a633786d4cf618" -dependencies = [ - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "unsafe-any-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a303d30665362d9680d7d91d78b23f5f899504d4f08b3c4cf08d055d87c0ad" -dependencies = [ - "destructure_traitobject", -] - -[[package]] -name = "untrusted" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" - -[[package]] -name = "ureq" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b8b063c2d59218ae09f22b53c42eaad0d53516457905f5235ca4bc9e99daa71" -dependencies = [ - "base64 0.13.1", - "chunked_transfer", - "log", - "native-tls", - "once_cell", - "qstring", - "serde", - "serde_json", - "url", -] - -[[package]] -name = "url" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - -[[package]] -name = "using_queue" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" - -[[package]] -name = "uuid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" -dependencies = [ - "getrandom 0.2.10", - "serde", -] - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "vm" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "byteorder", - "ethereum-types 0.4.2", - "ethjson", - "keccak-hash 0.1.2", - "log", - "parity-bytes", - "patricia-trie-ethereum", - "rlp 0.3.0", - "trie-db", -] - -[[package]] -name = "vrf" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff9943db5840ba292776c3778fedf9b97e11166d8222eceb2cb330f1ea08945" -dependencies = [ - "failure", - "hmac-sha256", - "openssl", -] - -[[package]] -name = "waker-fn" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" - -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-ethereum?tag=v2.4.0#c7d8ee1dd7c5d0167b589616c77945abdc5c5928" -dependencies = [ - "byteorder", - "ethereum-types 0.4.2", - "libc", - "log", - "parity-wasm", - "pwasm-utils", - "vm", - "wasmi", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" -dependencies = [ - "quote 1.0.33", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" - -[[package]] -name = "wasmi" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b4a6d379e9332b1b1f52c5a87f2481c85c7c931d8ec411963dfb8f26b1ec1e3" -dependencies = [ - "byteorder", - "memory_units", - "nan-preserving-float", - "parity-wasm", -] - -[[package]] -name = "wayland-scanner" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "xml-rs", -] - -[[package]] -name = "web-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "wgpu" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "480c965c9306872eb6255fa55e4b4953be55a8b64d57e61d7ff840d3dcc051cd" -dependencies = [ - "arrayvec 0.7.4", - "cfg-if 1.0.0", - "js-sys", - "log", - "naga", - "parking_lot 0.12.1", - "profiling", - "raw-window-handle", - "smallvec 1.11.1", - "static_assertions", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "wgpu-core", - "wgpu-hal", - "wgpu-types", -] - -[[package]] -name = "wgpu-core" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f478237b4bf0d5b70a39898a66fa67ca3a007d79f2520485b8b0c3dfc46f8c2" -dependencies = [ - "arrayvec 0.7.4", - "bit-vec 0.6.3", - "bitflags 2.4.1", - "codespan-reporting", - "log", - "naga", - "parking_lot 0.12.1", - "profiling", - "raw-window-handle", - "rustc-hash", - "smallvec 1.11.1", - "thiserror", - "web-sys", - "wgpu-hal", - "wgpu-types", -] - -[[package]] -name = "wgpu-hal" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecb3258078e936deee14fd4e0febe1cfe9bbb5ffef165cb60218d2ee5eb4448" -dependencies = [ - "android_system_properties", - "arrayvec 0.7.4", - "ash", - "bit-set 0.5.3", - "bitflags 2.4.1", - "block", - "core-graphics-types", - "d3d12", - "foreign-types", - "glow", - "gpu-alloc", - "gpu-allocator", - "gpu-descriptor", - "hassle-rs", - "js-sys", - "khronos-egl", - "libc", - "libloading 0.8.1", - "log", - "metal", - "naga", - "objc", - "parking_lot 0.12.1", - "profiling", - "range-alloc", - "raw-window-handle", - "renderdoc-sys", - "rustc-hash", - "smallvec 1.11.1", - "thiserror", - "wasm-bindgen", - "web-sys", - "wgpu-types", - "winapi 0.3.9", -] - -[[package]] -name = "wgpu-types" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c153280bb108c2979eb5c7391cb18c56642dd3c072e55f52065e13e2a1252a" -dependencies = [ - "bitflags 2.4.1", - "js-sys", - "web-sys", -] - -[[package]] -name = "widestring" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.44.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-targets 0.48.5", -] - -[[package]] -name = "windows" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" -dependencies = [ - "windows-core", - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-core" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-implement" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "windows-interface" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 1.0.109", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "winit" -version = "0.28.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9596d90b45384f5281384ab204224876e8e8bf7d58366d9b795ad99aa9894b94" -dependencies = [ - "android-activity", - "bitflags 1.3.2", - "cfg_aliases", - "core-foundation", - "core-graphics", - "dispatch", - "instant", - "libc", - "log", - "mio 0.8.8", - "ndk", - "objc2", - "once_cell", - "orbclient", - "percent-encoding", - "raw-window-handle", - "redox_syscall 0.3.5", - "wasm-bindgen", - "wayland-scanner", - "web-sys", - "windows-sys 0.45.0", - "x11-dl", -] - -[[package]] -name = "winnow" -version = "0.5.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" -dependencies = [ - "memchr", -] - -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "x11-dl" -version = "2.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" -dependencies = [ - "libc", - "once_cell", - "pkg-config", -] - -[[package]] -name = "x25519-dalek-fiat" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f3519d56987103ef084eba6ddfc3be45b7eaee08f2d60bc8495cdca30362a32" -dependencies = [ - "curve25519-dalek-fiat", - "rand_core 0.6.4", - "zeroize", -] - -[[package]] -name = "xi-unicode" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67300977d3dc3f8034dae89778f502b6ba20b269527b3223ba59c0cf393bb8a" - -[[package]] -name = "xml-rs" -version = "0.8.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" - -[[package]] -name = "xmltree" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb" -dependencies = [ - "xml-rs", -] - -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "zeroize" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2 1.0.69", - "quote 1.0.33", - "syn 2.0.38", -] - -[[package]] -name = "zstd-sys" -version = "1.6.3+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" -dependencies = [ - "cc", - "libc", -] diff --git a/core/src/executive/README.md b/core/src/executive/README.md deleted file mode 100644 index 071d617821..0000000000 --- a/core/src/executive/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# execution - -core/execution/ contains types and implementation to facilite execution of transactions. diff --git a/core/src/executive/executive.rs b/core/src/executive/executive.rs deleted file mode 100644 index babbcad918..0000000000 --- a/core/src/executive/executive.rs +++ /dev/null @@ -1,2035 +0,0 @@ -// Copyright 2019 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -use super::{context::OriginInfo, Executed, ExecutionError}; -use crate::{ - builtin::Builtin, - bytes::Bytes, - evm::{FinalizationResult, Finalize}, - executive::{ - context::LocalContext, - executed::{ExecutionOutcome, ToRepackError, TxDropError}, - internal_contract::InternalContractTrait, - vm_exec::{BuiltinExec, InternalContractExec, NoopExec}, - CollateralCheckResultToVmResult, - }, - hash::keccak, - machine::Machine, - observer::{ - tracer::ExecutiveTracer, AddressPocket, GasMan, StateTracer, VmObserve, - }, - state::{ - cleanup_mode, settle_collateral_for_all, CallStackInfo, State, Substate, - }, - verification::VerificationConfig, - vm::{ - self, ActionParams, ActionValue, CallType, CreateContractAddress, - CreateType, Env, Exec, ExecTrapError, ExecTrapResult, GasLeft, - ResumeCall, ResumeCreate, ReturnData, Spec, TrapError, TrapResult, - }, - vm_factory::VmFactory, -}; -use cfx_parameters::{consensus::ONE_CFX_IN_DRIP, staking::*}; -use cfx_state::{CleanupMode, CollateralCheckResult}; -use cfx_statedb::Result as DbResult; -use cfx_types::{ - address_util::AddressUtil, Address, AddressSpaceUtil, AddressWithSpace, - Space, H256, U256, U512, U64, -}; -use primitives::{ - receipt::StorageChange, storage::STORAGE_LAYOUT_REGULAR_V0, - transaction::Action, NativeTransaction, SignedTransaction, StorageLayout, - Transaction, -}; -use rlp::RlpStream; -use std::{ - cmp::{max, min}, - collections::HashSet, - convert::{TryFrom, TryInto}, - ops::Shl, - sync::Arc, -}; - -/// Calculate new contract address. -pub fn contract_address( - address_scheme: CreateContractAddress, _block_number: U64, - sender: &AddressWithSpace, nonce: &U256, code: &[u8], -) -> (AddressWithSpace, Option) -{ - let code_hash = keccak(code); - let (address, code_hash) = match address_scheme { - CreateContractAddress::FromSenderNonce => { - assert_eq!(sender.space, Space::Ethereum); - let mut rlp = RlpStream::new_list(2); - rlp.append(&sender.address); - rlp.append(nonce); - let h = Address::from(keccak(rlp.as_raw())); - (h, Some(code_hash)) - } - CreateContractAddress::FromBlockNumberSenderNonceAndCodeHash => { - unreachable!("Inactive setting"); - // let mut buffer = [0u8; 1 + 8 + 20 + 32 + 32]; - // let (lead_bytes, rest) = buffer.split_at_mut(1); - // let (block_number_bytes, rest) = rest.split_at_mut(8); - // let (sender_bytes, rest) = - // rest.split_at_mut(Address::len_bytes()); - // let (nonce_bytes, code_hash_bytes) = - // rest.split_at_mut(H256::len_bytes()); - // // In Conflux, we take block_number and CodeHash into address - // // calculation. This is required to enable us to clean - // // up unused user account in future. - // lead_bytes[0] = 0x0; - // block_number.to_little_endian(block_number_bytes); - // sender_bytes.copy_from_slice(&sender.address[..]); - // nonce.to_little_endian(nonce_bytes); - // code_hash_bytes.copy_from_slice(&code_hash[..]); - // // In Conflux, we use the first four bits to indicate the type of - // // the address. For contract address, the bits will be - // // set to 0x8. - // let mut h = Address::from(keccak(&buffer[..])); - // h.set_contract_type_bits(); - // (h, Some(code_hash)) - } - CreateContractAddress::FromSenderNonceAndCodeHash => { - assert_eq!(sender.space, Space::Native); - let mut buffer = [0u8; 1 + 20 + 32 + 32]; - // In Conflux, we append CodeHash to determine the address as well. - // This is required to enable us to clean up unused user account in - // future. - buffer[0] = 0x0; - buffer[1..(1 + 20)].copy_from_slice(&sender.address[..]); - nonce.to_little_endian(&mut buffer[(1 + 20)..(1 + 20 + 32)]); - buffer[(1 + 20 + 32)..].copy_from_slice(&code_hash[..]); - // In Conflux, we use the first four bits to indicate the type of - // the address. For contract address, the bits will be - // set to 0x8. - let mut h = Address::from(keccak(&buffer[..])); - h.set_contract_type_bits(); - (h, Some(code_hash)) - } - CreateContractAddress::FromSenderSaltAndCodeHash(salt) => { - let mut buffer = [0u8; 1 + 20 + 32 + 32]; - buffer[0] = 0xff; - buffer[1..(1 + 20)].copy_from_slice(&sender.address[..]); - buffer[(1 + 20)..(1 + 20 + 32)].copy_from_slice(&salt[..]); - buffer[(1 + 20 + 32)..].copy_from_slice(&code_hash[..]); - // In Conflux, we use the first bit to indicate the type of the - // address. For contract address, the bits will be set to 0x8. - let mut h = Address::from(keccak(&buffer[..])); - if sender.space == Space::Native { - h.set_contract_type_bits(); - } - (h, Some(code_hash)) - } - }; - return (address.with_space(sender.space), code_hash); -} - -/// Convert a finalization result into a VM message call result. -pub fn into_message_call_result( - result: vm::Result, -) -> vm::MessageCallResult { - match result { - Ok(ExecutiveResult { - gas_left, - return_data, - apply_state: true, - .. - }) => vm::MessageCallResult::Success(gas_left, return_data), - Ok(ExecutiveResult { - gas_left, - return_data, - apply_state: false, - .. - }) => vm::MessageCallResult::Reverted(gas_left, return_data), - Err(err) => vm::MessageCallResult::Failed(err), - } -} - -/// Convert a finalization result into a VM contract create result. -pub fn into_contract_create_result( - result: vm::Result, -) -> vm::ContractCreateResult { - match result { - Ok(ExecutiveResult { - space, - gas_left, - apply_state: true, - create_address, - .. - }) => { - // Move the change of contracts_created in substate to - // process_return. - let address = create_address - .expect("ExecutiveResult for Create executive should be some."); - let address = AddressWithSpace { address, space }; - vm::ContractCreateResult::Created(address, gas_left) - } - Ok(ExecutiveResult { - gas_left, - apply_state: false, - return_data, - .. - }) => vm::ContractCreateResult::Reverted(gas_left, return_data), - Err(err) => vm::ContractCreateResult::Failed(err), - } -} - -/// Transaction execution options. -pub struct TransactOptions { - pub observer: Observer, - pub check_settings: TransactCheckSettings, -} - -impl TransactOptions { - pub fn exec_with_tracing() -> Self { - Self { - observer: Observer::with_tracing(), - check_settings: TransactCheckSettings::all_checks(), - } - } - - pub fn exec_with_no_tracing() -> Self { - Self { - observer: Observer::with_no_tracing(), - check_settings: TransactCheckSettings::all_checks(), - } - } - - pub fn estimate_first_pass(request: EstimateRequest) -> Self { - Self { - observer: Observer::virtual_call(), - check_settings: TransactCheckSettings::from_estimate_request( - request, - ChargeCollateral::EstimateSender, - ), - } - } - - pub fn estimate_second_pass(request: EstimateRequest) -> Self { - Self { - observer: Observer::virtual_call(), - check_settings: TransactCheckSettings::from_estimate_request( - request, - ChargeCollateral::EstimateSponsor, - ), - } - } -} - -#[derive(Debug, Clone, Copy)] -pub enum ChargeCollateral { - Normal, - EstimateSender, - EstimateSponsor, -} - -#[derive(Debug, Clone, Copy)] -pub struct EstimateRequest { - pub has_sender: bool, - pub has_gas_limit: bool, - pub has_gas_price: bool, - pub has_nonce: bool, - pub has_storage_limit: bool, -} - -impl EstimateRequest { - fn recheck_gas_fee(&self) -> bool { self.has_sender && self.has_gas_price } - - fn charge_gas(&self) -> bool { - self.has_sender && self.has_gas_limit && self.has_gas_price - } -} - -#[derive(Debug, Clone, Copy)] -pub struct TransactCheckSettings { - pub charge_collateral: ChargeCollateral, - pub charge_gas: bool, - pub real_execution: bool, - pub check_epoch_height: bool, -} - -impl TransactCheckSettings { - fn all_checks() -> Self { - Self { - charge_collateral: ChargeCollateral::Normal, - charge_gas: true, - real_execution: true, - check_epoch_height: true, - } - } - - fn from_estimate_request( - request: EstimateRequest, charge_collateral: ChargeCollateral, - ) -> Self { - Self { - charge_collateral, - charge_gas: request.charge_gas(), - real_execution: false, - check_epoch_height: false, - } - } -} - -pub struct Observer { - pub tracer: Option, - pub gas_man: Option, - _noop: (), -} - -impl Observer { - pub fn as_vm_observe<'a>(&'a mut self) -> Box { - match (self.tracer.as_mut(), self.gas_man.as_mut()) { - (Some(tracer), Some(gas_man)) => Box::new((tracer, gas_man)), - (Some(tracer), None) => Box::new(tracer), - (None, Some(gas_man)) => Box::new(gas_man), - (None, None) => Box::new(&mut self._noop), - } - } - - pub fn as_state_tracer(&mut self) -> &mut dyn StateTracer { - match self.tracer.as_mut() { - None => &mut self._noop, - Some(tracer) => tracer, - } - } - - fn with_tracing() -> Self { - Observer { - tracer: Some(ExecutiveTracer::default()), - gas_man: None, - _noop: (), - } - } - - fn with_no_tracing() -> Self { - Observer { - tracer: None, - gas_man: None, - _noop: (), - } - } - - fn virtual_call() -> Self { - Observer { - tracer: Some(ExecutiveTracer::default()), - gas_man: Some(GasMan::default()), - _noop: (), - } - } -} - -enum CallCreateExecutiveKind<'a> { - Transfer, - CallBuiltin(&'a Builtin), - CallInternalContract(&'a Box), - ExecCall, - ExecCreate, -} - -pub struct CallCreateExecutive<'a> { - context: LocalContext<'a>, - factory: &'a VmFactory, - status: ExecutiveStatus, - create_address: Option
, - kind: CallCreateExecutiveKind<'a>, -} - -pub enum ExecutiveStatus { - Input(ActionParams), - Running, - ResumeCall(Box), - ResumeCreate(Box), - Done, -} - -impl<'a> CallCreateExecutive<'a> { - /// Create a new call executive using raw data. - pub fn new_call_raw( - params: ActionParams, env: &'a Env, machine: &'a Machine, - spec: &'a Spec, factory: &'a VmFactory, depth: usize, - parent_static_flag: bool, - ) -> Self - { - trace!( - "Executive::call(params={:?}) self.env={:?}, parent_static={}", - params, - env, - parent_static_flag, - ); - - let static_flag = - parent_static_flag || params.call_type == CallType::StaticCall; - - let substate = Substate::new(); - // This logic is moved from function exec. - let origin = OriginInfo::from(¶ms); - let code_address = AddressWithSpace { - address: params.code_address, - space: params.space, - }; - - // Builtin is located for both Conflux Space and EVM Space. - let kind = - if let Some(builtin) = machine.builtin(&code_address, env.number) { - trace!("CallBuiltin"); - CallCreateExecutiveKind::CallBuiltin(builtin) - } else if let Some(internal) = - machine.internal_contracts().contract(&code_address, spec) - { - debug!( - "CallInternalContract: address={:?} data={:?}", - code_address, params.data - ); - CallCreateExecutiveKind::CallInternalContract(internal) - } else { - if params.code.is_some() { - trace!("ExecCall"); - CallCreateExecutiveKind::ExecCall - } else { - trace!("Transfer"); - CallCreateExecutiveKind::Transfer - } - }; - let context = LocalContext::new( - params.space, - env, - machine, - spec, - depth, - origin, - substate, - /* is_create: */ false, - static_flag, - ); - Self { - context, - factory, - // Instead of put params to Exective kind, we put it into status. - status: ExecutiveStatus::Input(params), - create_address: None, - kind, - } - } - - /// Create a new create executive using raw data. - pub fn new_create_raw( - params: ActionParams, env: &'a Env, machine: &'a Machine, - spec: &'a Spec, factory: &'a VmFactory, depth: usize, - static_flag: bool, - ) -> Self - { - trace!( - "Executive::create(params={:?}) self.env={:?}, static={}", - params, - env, - static_flag - ); - - let origin = OriginInfo::from(¶ms); - - let kind = CallCreateExecutiveKind::ExecCreate; - - let substate = Substate::new(); - - let context = LocalContext::new( - params.space, - env, - machine, - spec, - depth, - origin, - substate, - /* is_create */ true, - static_flag, - ); - - Self { - context, - create_address: Some(params.code_address), - status: ExecutiveStatus::Input(params), - factory, - kind, - } - } - - /// This executive always contain an unconfirmed substate, returns a mutable - /// reference to it. - pub fn unconfirmed_substate(&mut self) -> &mut Substate { - &mut self.context.substate - } - - /// Get the recipient of this executive. The recipient is the address whose - /// state will change. - pub fn get_recipient(&self) -> &Address { &self.context.origin.recipient() } - - fn check_static_flag( - params: &ActionParams, static_flag: bool, is_create: bool, - ) -> vm::Result<()> { - // This is the function check whether contract creation or value - // transferring happens in static context at callee executive. However, - // it is meaningless because the caller has checked this constraint - // before message call. Currently, if we panic when this - // function returns error, all the tests can still pass. - // So we no longer check the logic for reentrancy here, - // TODO: and later we will check if we can safely remove this function. - if is_create { - if static_flag { - return Err(vm::Error::MutableCallInStaticContext); - } - } else { - if static_flag - && (params.call_type == CallType::StaticCall - || params.call_type == CallType::Call) - && params.value.value() > U256::zero() - { - return Err(vm::Error::MutableCallInStaticContext); - } - } - - Ok(()) - } - - fn transfer_exec_balance( - params: &ActionParams, spec: &Spec, state: &mut State, - substate: &mut Substate, - ) -> DbResult<()> - { - let sender = AddressWithSpace { - address: params.sender, - space: params.space, - }; - let receiver = AddressWithSpace { - address: params.address, - space: params.space, - }; - if let ActionValue::Transfer(val) = params.value { - state.transfer_balance( - &sender, - &receiver, - &val, - cleanup_mode(substate, &spec), - )?; - } - - Ok(()) - } - - fn transfer_exec_balance_and_init_contract( - params: &ActionParams, spec: &Spec, state: &mut State, - substate: &mut Substate, storage_layout: Option, - ) -> DbResult<()> - { - let sender = AddressWithSpace { - address: params.sender, - space: params.space, - }; - let receiver = AddressWithSpace { - address: params.address, - space: params.space, - }; - if let ActionValue::Transfer(val) = params.value { - // It is possible to first send money to a pre-calculated - // contract address. - let prev_balance = state.balance(&receiver)?; - state.sub_balance( - &sender, - &val, - &mut cleanup_mode(substate, &spec), - )?; - let admin = if params.space == Space::Native { - params.original_sender - } else { - Address::zero() - }; - state.new_contract_with_admin( - &receiver, - &admin, - val.saturating_add(prev_balance), - storage_layout, - spec.cip107, - )?; - } else { - // In contract creation, the `params.value` should never be - // `Apparent`. - unreachable!(); - } - - Ok(()) - } - - /// When the executive (the inner EVM) returns, this function will process - /// the rest tasks: If the execution successes, this function collects - /// storage collateral change from the cache to substate, merge substate to - /// its parent and settles down bytecode for newly created contract. If the - /// execution fails, this function reverts state and drops substate. - fn process_return( - mut self, result: vm::Result, state: &mut State, - callstack: &mut CallStackInfo, tracer: &mut dyn VmObserve, - ) -> DbResult> - { - let context = self.context.activate(state, callstack); - // The post execution task in spec is completed here. - let finalized_result = result.finalize(context); - let finalized_result = vm::separate_out_db_error(finalized_result)?; - - self.status = ExecutiveStatus::Done; - - let apply_state = - finalized_result.as_ref().map_or(false, |r| r.apply_state); - let maybe_substate; - if apply_state { - let mut substate = self.context.substate; - state.collect_ownership_changed(&mut substate)?; /* only fail for db error. */ - if let Some(create_address) = self.create_address { - substate - .contracts_created - .push(create_address.with_space(self.context.space)); - } - maybe_substate = Some(substate); - state.discard_checkpoint(); - } else { - maybe_substate = None; - state.revert_to_checkpoint(); - } - - let create_address = self.create_address; - let executive_result = finalized_result.map(|result| { - ExecutiveResult::new(result, create_address, maybe_substate) - }); - if self.context.is_create { - tracer.record_create_result(&executive_result); - } else { - tracer.record_call_result(&executive_result); - } - - callstack.pop(); - - Ok(executive_result) - } - - /// If the executive triggers a sub-call during execution, this function - /// outputs a trap error with sub-call parameters and return point. - fn process_trap( - mut self, trap_err: ExecTrapError, - ) -> ExecutiveTrapError<'a> { - match trap_err { - TrapError::Call(subparams, resume) => { - self.status = ExecutiveStatus::ResumeCall(resume); - TrapError::Call(subparams, self) - } - TrapError::Create(subparams, resume) => { - self.status = ExecutiveStatus::ResumeCreate(resume); - TrapError::Create(subparams, self) - } - } - } - - /// Execute the executive. If a sub-call/create action is required, a - /// resume trap error is returned. The caller is then expected to call - /// `resume` to continue the execution. - pub fn exec( - mut self, state: &mut State, callstack: &mut CallStackInfo, - tracer: &mut dyn VmObserve, - ) -> DbResult> - { - let status = - std::mem::replace(&mut self.status, ExecutiveStatus::Running); - let params = if let ExecutiveStatus::Input(params) = status { - params - } else { - panic!("Status should be input parameter") - }; - - let is_create = self.create_address.is_some(); - assert_eq!(is_create, self.context.is_create); - - // By technical specification and current implementation, the EVM should - // guarantee the current executive satisfies static_flag. - Self::check_static_flag(¶ms, self.context.static_flag, is_create) - .expect("check_static_flag should always success because EVM has checked it."); - - // Trace task - if is_create { - debug!( - "CallCreateExecutiveKind::ExecCreate: contract_addr = {:?}", - params.address - ); - tracer.record_create(¶ms); - } else { - tracer.record_call(¶ms); - } - - // Make checkpoint for this executive, callstack is always maintained - // with checkpoint. - state.checkpoint(); - - let contract_address = self.get_recipient().clone(); - callstack - .push(contract_address.with_space(self.context.space), is_create); - - // Pre execution: transfer value and init contract. - let spec = self.context.spec; - if is_create { - Self::transfer_exec_balance_and_init_contract( - ¶ms, - spec, - state, - // It is a bug in the Parity version. - &mut self.context.substate, - Some(STORAGE_LAYOUT_REGULAR_V0), - )? - } else { - Self::transfer_exec_balance( - ¶ms, - spec, - state, - &mut self.context.substate, - )? - }; - - // Fetch execution model and execute - let exec: Box = match self.kind { - CallCreateExecutiveKind::Transfer => { - Box::new(NoopExec { gas: params.gas }) - } - CallCreateExecutiveKind::CallBuiltin(builtin) => { - Box::new(BuiltinExec { builtin, params }) - } - CallCreateExecutiveKind::CallInternalContract(internal) => { - Box::new(InternalContractExec { internal, params }) - } - CallCreateExecutiveKind::ExecCall - | CallCreateExecutiveKind::ExecCreate => { - let factory = self.context.machine.vm_factory(); - factory.create(params, self.context.spec, self.context.depth) - } - }; - let mut context = self.context.activate(state, callstack); - let output = exec.exec(&mut context, tracer); - - // Post execution. - self.process_output(output, state, callstack, tracer) - } - - pub fn resume( - mut self, mut result: vm::Result, state: &mut State, - callstack: &mut CallStackInfo, tracer: &mut dyn VmObserve, - ) -> DbResult> - { - let status = - std::mem::replace(&mut self.status, ExecutiveStatus::Running); - - accrue_substate(self.unconfirmed_substate(), &mut result); - - // Process resume tasks, which is defined in Instruction Set - // Specification of tech-specification. - let exec = match status { - ExecutiveStatus::ResumeCreate(resume) => { - let result = into_contract_create_result(result); - resume.resume_create(result) - } - ExecutiveStatus::ResumeCall(resume) => { - let result = into_message_call_result(result); - resume.resume_call(result) - } - ExecutiveStatus::Input(_) - | ExecutiveStatus::Done - | ExecutiveStatus::Running => { - panic!("Incorrect executive status in resume"); - } - }; - - let mut context = self.context.activate(state, callstack); - let output = exec.exec(&mut context, tracer); - - // Post execution. - self.process_output(output, state, callstack, tracer) - } - - #[inline] - fn process_output( - self, output: ExecTrapResult, state: &mut State, - callstack: &mut CallStackInfo, tracer: &mut dyn VmObserve, - ) -> DbResult> - { - // Convert the `ExecTrapResult` (result of evm) to `ExecutiveTrapResult` - // (result of self). - let trap_result = match output { - TrapResult::Return(result) => TrapResult::Return( - self.process_return(result, state, callstack, tracer)?, - ), - TrapResult::SubCallCreate(trap_err) => { - TrapResult::SubCallCreate(self.process_trap(trap_err)) - } - }; - Ok(trap_result) - } - - /// Execute the top call-create executive. This function handles resume - /// traps and sub-level tracing. The caller is expected to handle - /// current-level tracing. - pub fn consume( - self, state: &'a mut State, top_substate: &mut Substate, - tracer: &mut dyn VmObserve, - ) -> DbResult> - { - let mut callstack = CallStackInfo::new(); - let mut executive_stack: Vec = Vec::new(); - - let mut last_res = self.exec(state, &mut callstack, tracer)?; - - loop { - last_res = match last_res { - TrapResult::Return(mut result) => { - let parent = match executive_stack.pop() { - Some(x) => x, - None => { - accrue_substate(top_substate, &mut result); - return Ok(result.map(Into::into)); - } - }; - - parent.resume(result, state, &mut callstack, tracer)? - } - TrapResult::SubCallCreate(trap_err) => { - let (callee, caller) = Self::from_trap_error(trap_err); - executive_stack.push(caller); - - callee.exec(state, &mut callstack, tracer)? - } - } - } - } - - /// Output callee executive and caller executive from trap kind error. - pub fn from_trap_error(trap_err: ExecutiveTrapError<'a>) -> (Self, Self) { - match trap_err { - TrapError::Call(params, parent) => ( - /* callee */ - CallCreateExecutive::new_call_raw( - params, - parent.context.env, - parent.context.machine, - parent.context.spec, - parent.factory, - parent.context.depth + 1, - parent.context.static_flag, - ), - /* caller */ parent, - ), - TrapError::Create(params, parent) => ( - /* callee */ - CallCreateExecutive::new_create_raw( - params, - parent.context.env, - parent.context.machine, - parent.context.spec, - parent.factory, - parent.context.depth + 1, - parent.context.static_flag, - ), - /* callee */ parent, - ), - } - } -} - -pub fn accrue_substate( - parent_substate: &mut Substate, result: &mut vm::Result, -) { - if let Ok(frame_return) = result { - if let Some(substate) = std::mem::take(&mut frame_return.substate) { - parent_substate.accrue(substate); - } - } -} - -/// The result contains more data than finalization result. -#[derive(Debug)] -pub struct ExecutiveResult { - /// Space - pub space: Space, - /// Final amount of gas left. - pub gas_left: U256, - /// Apply execution state changes or revert them. - pub apply_state: bool, - /// Return data buffer. - pub return_data: ReturnData, - /// Create address. - pub create_address: Option
, - /// Substate. - pub substate: Option, -} - -impl Into for ExecutiveResult { - fn into(self) -> FinalizationResult { - FinalizationResult { - space: self.space, - gas_left: self.gas_left, - apply_state: self.apply_state, - return_data: self.return_data, - } - } -} - -impl ExecutiveResult { - fn new( - result: FinalizationResult, create_address: Option
, - substate: Option, - ) -> Self - { - ExecutiveResult { - space: result.space, - gas_left: result.gas_left, - apply_state: result.apply_state, - return_data: result.return_data, - create_address, - substate, - } - } -} - -/// Trap result returned by executive. -pub type ExecutiveTrapResult<'a, T> = - vm::TrapResult, CallCreateExecutive<'a>>; - -pub type ExecutiveTrapError<'a> = - vm::TrapError, CallCreateExecutive<'a>>; - -pub type Executive<'a> = ExecutiveGeneric<'a>; - -/// Transaction executor. -pub struct ExecutiveGeneric<'a> { - pub state: &'a mut State, - env: &'a Env, - machine: &'a Machine, - spec: &'a Spec, - depth: usize, - static_flag: bool, -} - -struct SponsorCheckOutput { - sender_intended_cost: U512, - total_cost: U512, - gas_sponsored: bool, - storage_sponsored: bool, - storage_sponsor_eligible: bool, -} - -pub fn gas_required_for(is_create: bool, data: &[u8], spec: &Spec) -> u64 { - data.iter().fold( - (if is_create { - spec.tx_create_gas - } else { - spec.tx_gas - }) as u64, - |g, b| { - g + (match *b { - 0 => spec.tx_data_zero_gas, - _ => spec.tx_data_non_zero_gas, - }) as u64 - }, - ) -} - -impl<'a> ExecutiveGeneric<'a> { - /// Basic constructor. - pub fn new( - state: &'a mut State, env: &'a Env, machine: &'a Machine, - spec: &'a Spec, - ) -> Self - { - ExecutiveGeneric { - state, - env, - machine, - spec, - depth: 0, - static_flag: false, - } - } - - pub fn create( - &mut self, params: ActionParams, substate: &mut Substate, - tracer: &mut dyn VmObserve, - ) -> DbResult> - { - let vm_factory = self.machine.vm_factory(); - let result = CallCreateExecutive::new_create_raw( - params, - self.env, - self.machine, - self.spec, - &vm_factory, - self.depth, - self.static_flag, - ) - .consume(self.state, substate, tracer)?; - - Ok(result) - } - - pub fn call( - &mut self, params: ActionParams, substate: &mut Substate, - tracer: &mut dyn VmObserve, - ) -> DbResult> - { - let vm_factory = self.machine.vm_factory(); - let result = CallCreateExecutive::new_call_raw( - params, - self.env, - self.machine, - self.spec, - &vm_factory, - self.depth, - self.static_flag, - ) - .consume(self.state, substate, tracer)?; - - Ok(result) - } - - pub fn transact_virtual( - &mut self, mut tx: SignedTransaction, request: EstimateRequest, - ) -> DbResult { - let is_native_tx = tx.space() == Space::Native; - let request_storage_limit = tx.storage_limit(); - - if !request.has_sender { - let mut random_hex = Address::random(); - if is_native_tx { - random_hex.set_user_account_type_bits(); - } - tx.sender = random_hex; - tx.public = None; - - // If the sender is not specified, give it enough balance: 1 billion - // CFX. - let balance_inc = min( - tx.value().saturating_add( - U256::from(1_000_000_000) * ONE_CFX_IN_DRIP, - ), - U256::one().shl(128), - ); - - self.state.add_balance( - &random_hex.with_space(tx.space()), - &balance_inc, - CleanupMode::NoEmpty, - )?; - // Make sure statistics are also correct and will not violate any - // underlying assumptions. - self.state.add_total_issued(balance_inc); - if tx.space() == Space::Ethereum { - self.state.add_total_evm_tokens(balance_inc); - } - } - - if request.has_nonce { - self.state.set_nonce(&tx.sender(), &tx.nonce())?; - } else { - *tx.nonce_mut() = self.state.nonce(&tx.sender())?; - } - - let balance = self.state.balance(&tx.sender())?; - - // For the same transaction, the storage limit paid by user and the - // storage limit paid by the sponsor are different values. So - // this function will - // - // 1. First Pass: Assuming the sponsor pays for storage collateral, - // check if the transaction will fail for - // NotEnoughBalanceForStorage. - // - // 2. Second Pass: If it does, executes the transaction again assuming - // the user pays for the storage collateral. The resultant - // storage limit must be larger than the maximum storage limit - // can be afford by the sponsor, to guarantee the user pays for - // the storage limit. - - // First pass - self.state.checkpoint(); - let sender_pay_executed = match self - .transact(&tx, TransactOptions::estimate_first_pass(request))? - { - ExecutionOutcome::Finished(executed) => executed, - res => { - return Ok(res); - } - }; - debug!( - "Transaction estimate first pass outcome {:?}", - sender_pay_executed - ); - self.state.revert_to_checkpoint(); - - // Second pass - let mut contract_pay_executed: Option = None; - let mut native_to_contract: Option
= None; - let mut sponsor_for_collateral_eligible = false; - if let Transaction::Native(NativeTransaction { - action: Action::Call(ref to), - .. - }) = tx.unsigned - { - if to.is_contract_address() { - native_to_contract = Some(*to); - let has_sponsor = self - .state - .sponsor_for_collateral(&to)? - .map_or(false, |x| !x.is_zero()); - - if has_sponsor - && (self - .state - .check_contract_whitelist(&to, &tx.sender().address)? - || self - .state - .check_contract_whitelist(&to, &Address::zero())?) - { - sponsor_for_collateral_eligible = true; - - self.state.checkpoint(); - let res = self.transact( - &tx, - TransactOptions::estimate_second_pass(request), - )?; - self.state.revert_to_checkpoint(); - - contract_pay_executed = match res { - ExecutionOutcome::Finished(executed) => Some(executed), - res => { - warn!("Should unreachable because two pass estimations should have the same output. \ - Now we have: first pass success {:?}, second pass fail {:?}", sender_pay_executed, res); - None - } - }; - debug!( - "Transaction estimate second pass outcome {:?}", - contract_pay_executed - ); - } - } - }; - - let overwrite_storage_limit = - |mut executed: Executed, max_sponsor_storage_limit: u64| { - debug!("Transaction estimate overwrite the storage limit to overcome sponsor_balance_for_collateral."); - executed.estimated_storage_limit = max( - executed.estimated_storage_limit, - max_sponsor_storage_limit + 64, - ); - executed - }; - - let mut executed = if !sponsor_for_collateral_eligible { - sender_pay_executed - } else { - let contract_address = native_to_contract.as_ref().unwrap(); - let sponsor_balance_for_collateral = self - .state - .sponsor_balance_for_collateral(contract_address)? - + self.state.available_storage_points_for_collateral( - contract_address, - )?; - let max_sponsor_storage_limit = (sponsor_balance_for_collateral - / *DRIPS_PER_STORAGE_COLLATERAL_UNIT) - .as_u64(); - if let Some(contract_pay_executed) = contract_pay_executed { - if max_sponsor_storage_limit - >= contract_pay_executed.estimated_storage_limit - { - contract_pay_executed - } else { - overwrite_storage_limit( - sender_pay_executed, - max_sponsor_storage_limit, - ) - } - } else { - overwrite_storage_limit( - sender_pay_executed, - max_sponsor_storage_limit, - ) - } - }; - - // Revise the gas used in result, if we estimate the transaction with a - // default large enough gas. - if !request.has_gas_limit { - let estimated_gas_limit = executed.estimated_gas_limit.unwrap(); - executed.gas_charged = max( - estimated_gas_limit - estimated_gas_limit / 4, - executed.gas_used, - ); - executed.fee = executed.gas_charged.saturating_mul(*tx.gas_price()); - } - - // If we don't charge gas, recheck the current gas_fee is ok for - // sponsorship. - if !request.charge_gas() - && request.has_gas_price - && executed.gas_sponsor_paid - { - let enough_balance = executed.fee - <= self - .state - .sponsor_balance_for_gas(&native_to_contract.unwrap())?; - let enough_bound = executed.fee - <= self - .state - .sponsor_gas_bound(&native_to_contract.unwrap())?; - if !(enough_balance && enough_bound) { - debug!("Transaction estimate unset \"sponsor_paid\" because of not enough sponsor balance / gas bound."); - executed.gas_sponsor_paid = false; - } - } - - // If the request has a sender, recheck the balance requirement matched. - if request.has_sender { - // Unwrap safety: in given TransactOptions, this value must be - // `Some(_)`. - let gas_fee = - if request.recheck_gas_fee() && !executed.gas_sponsor_paid { - executed - .estimated_gas_limit - .unwrap() - .saturating_mul(*tx.gas_price()) - } else { - 0.into() - }; - let storage_collateral = if !executed.storage_sponsor_paid { - U256::from(executed.estimated_storage_limit) - * *DRIPS_PER_STORAGE_COLLATERAL_UNIT - } else { - 0.into() - }; - let value_and_fee = tx - .value() - .saturating_add(gas_fee) - .saturating_add(storage_collateral); - if balance < value_and_fee { - return Ok(ExecutionOutcome::ExecutionErrorBumpNonce( - ExecutionError::NotEnoughCash { - required: value_and_fee.into(), - got: balance.into(), - actual_gas_cost: min(balance, gas_fee), - max_storage_limit_cost: storage_collateral, - }, - executed, - )); - } - } - - if request.has_storage_limit { - let storage_limit = request_storage_limit.unwrap(); - if storage_limit < executed.estimated_storage_limit { - return Ok(ExecutionOutcome::ExecutionErrorBumpNonce( - ExecutionError::VmError(vm::Error::ExceedStorageLimit), - executed, - )); - } - } - - return Ok(ExecutionOutcome::Finished(executed)); - } - - fn sponsor_check( - &self, tx: &SignedTransaction, spec: &Spec, sender_balance: U512, - gas_cost: U512, storage_cost: U256, settings: &TransactCheckSettings, - ) -> DbResult> - { - let sender = tx.sender(); - // Check if contract will pay transaction fee for the sender. - let mut code_address = Address::zero(); - let mut gas_sponsor_eligible = false; - let mut storage_sponsor_eligible = false; - - if let Action::Call(ref address) = tx.action() { - if !spec.is_valid_address(address) { - return Ok(Err(ExecutionOutcome::NotExecutedDrop( - TxDropError::InvalidRecipientAddress(*address), - ))); - } - if self - .state - .is_contract_with_code(&address.with_native_space())? - { - code_address = *address; - if self - .state - .check_contract_whitelist(&code_address, &sender.address)? - { - // No need to check for gas sponsor account existence. - gas_sponsor_eligible = gas_cost - <= U512::from( - self.state.sponsor_gas_bound(&code_address)?, - ); - storage_sponsor_eligible = self - .state - .sponsor_for_collateral(&code_address)? - .is_some(); - } - } - } - - let code_address = code_address; - let gas_sponsor_eligible = gas_sponsor_eligible; - let storage_sponsor_eligible = storage_sponsor_eligible; - - // Sender pays for gas when sponsor runs out of balance. - let sponsor_balance_for_gas = - U512::from(self.state.sponsor_balance_for_gas(&code_address)?); - let gas_sponsored = - gas_sponsor_eligible && sponsor_balance_for_gas >= gas_cost; - - let sponsor_balance_for_storage = - self.state.sponsor_balance_for_collateral(&code_address)? - + self - .state - .available_storage_points_for_collateral(&code_address)?; - let storage_sponsored = match settings.charge_collateral { - ChargeCollateral::Normal => { - storage_sponsor_eligible - && storage_cost <= sponsor_balance_for_storage - } - ChargeCollateral::EstimateSender => false, - ChargeCollateral::EstimateSponsor => true, - }; - - let sender_intended_cost = { - let mut sender_intended_cost = U512::from(tx.value()); - - if !gas_sponsor_eligible { - sender_intended_cost += gas_cost; - } - if !storage_sponsor_eligible { - sender_intended_cost += storage_cost.into(); - } - sender_intended_cost - }; - let total_cost = { - let mut total_cost = U512::from(tx.value()); - if !gas_sponsored { - total_cost += gas_cost - } - if !storage_sponsored { - total_cost += storage_cost.into(); - } - total_cost - }; - // Sponsor is allowed however sender do not have enough balance to pay - // for the extra gas because sponsor has run out of balance in - // the mean time. - // - // Sender is not responsible for the incident, therefore we don't fail - // the transaction. - if sender_balance >= sender_intended_cost && sender_balance < total_cost - { - let gas_sponsor_balance = if gas_sponsor_eligible { - sponsor_balance_for_gas - } else { - 0.into() - }; - - let storage_sponsor_balance = if storage_sponsor_eligible { - sponsor_balance_for_storage - } else { - 0.into() - }; - - return Ok(Err(ExecutionOutcome::NotExecutedToReconsiderPacking( - ToRepackError::NotEnoughCashFromSponsor { - required_gas_cost: gas_cost, - gas_sponsor_balance, - required_storage_cost: storage_cost, - storage_sponsor_balance, - }, - ))); - } - - return Ok(Ok(SponsorCheckOutput { - sender_intended_cost, - total_cost, - gas_sponsored, - storage_sponsored, - // Only for backward compatible for a early bug. - // The receipt reported `storage_sponsor_eligible` instead of - // `storage_sponsored`. - storage_sponsor_eligible, - })); - } - - pub fn transact( - &mut self, tx: &SignedTransaction, options: TransactOptions, - ) -> DbResult { - let TransactOptions { - mut observer, - check_settings, - } = options; - - let spec = &self.spec; - let sender = tx.sender(); - let nonce = self.state.nonce(&sender)?; - - // Validate transaction nonce - if *tx.nonce() < nonce { - return Ok(ExecutionOutcome::NotExecutedDrop( - TxDropError::OldNonce(nonce, *tx.nonce()), - )); - } else if *tx.nonce() > nonce { - return Ok(ExecutionOutcome::NotExecutedToReconsiderPacking( - ToRepackError::InvalidNonce { - expected: nonce, - got: *tx.nonce(), - }, - )); - } - - // Validate transaction epoch height. - if let Transaction::Native(ref tx) = tx.transaction.transaction.unsigned - { - if check_settings.check_epoch_height - && VerificationConfig::check_transaction_epoch_bound( - tx, - self.env.epoch_height, - self.env.transaction_epoch_bound, - ) != 0 - { - return Ok(ExecutionOutcome::NotExecutedToReconsiderPacking( - ToRepackError::EpochHeightOutOfBound { - block_height: self.env.epoch_height, - set: tx.epoch_height, - transaction_epoch_bound: self - .env - .transaction_epoch_bound, - }, - )); - } - } - - let base_gas_required = - gas_required_for(tx.action() == &Action::Create, &tx.data(), spec); - assert!( - *tx.gas() >= base_gas_required.into(), - "We have already checked the base gas requirement when we received the block." - ); - - let balance = self.state.balance(&sender)?; - let gas_cost = if check_settings.charge_gas { - tx.gas().full_mul(*tx.gas_price()) - } else { - 0.into() - }; - let storage_cost = - if let (Transaction::Native(tx), ChargeCollateral::Normal) = ( - &tx.transaction.transaction.unsigned, - check_settings.charge_collateral, - ) { - U256::from(tx.storage_limit) - * *DRIPS_PER_STORAGE_COLLATERAL_UNIT - } else { - U256::zero() - }; - - let sender_balance = U512::from(balance); - - let SponsorCheckOutput { - sender_intended_cost, - total_cost, - gas_sponsored, - storage_sponsored, - storage_sponsor_eligible, - } = if sender.space == Space::Native { - match self.sponsor_check( - tx, - &spec, - sender_balance, - gas_cost, - storage_cost, - &check_settings, - )? { - Ok(res) => res, - Err(err) => { - return Ok(err); - } - } - } else { - let sender_cost = U512::from(tx.value()) + gas_cost; - SponsorCheckOutput { - sender_intended_cost: sender_cost, - total_cost: sender_cost, - gas_sponsored: false, - storage_sponsored: false, - storage_sponsor_eligible: false, - } - }; - - let mut tx_substate = Substate::new(); - if sender_balance < sender_intended_cost { - // Sender is responsible for the insufficient balance. - // Sub tx fee if not enough cash, and substitute all remaining - // balance if balance is not enough to pay the tx fee - let actual_gas_cost: U256 = - U512::min(gas_cost, sender_balance).try_into().unwrap(); - - // We don't want to bump nonce for non-existent account when we - // can't charge gas fee. In this case, the sender account will - // not be created if it does not exist. - if !self.state.exists(&sender)? && check_settings.real_execution { - return Ok(ExecutionOutcome::NotExecutedToReconsiderPacking( - ToRepackError::SenderDoesNotExist, - )); - } - self.state.inc_nonce(&sender)?; - self.state.sub_balance( - &sender, - &actual_gas_cost, - &mut cleanup_mode(&mut tx_substate, &spec), - )?; - observer.as_state_tracer().trace_internal_transfer( - AddressPocket::Balance(sender.address.with_space(tx.space())), - AddressPocket::GasPayment, - actual_gas_cost, - ); - if tx.space() == Space::Ethereum { - self.state.sub_total_evm_tokens(actual_gas_cost); - } - - return Ok(ExecutionOutcome::ExecutionErrorBumpNonce( - ExecutionError::NotEnoughCash { - required: total_cost, - got: sender_balance, - actual_gas_cost: actual_gas_cost.clone(), - max_storage_limit_cost: storage_cost, - }, - Executed::not_enough_balance_fee_charged( - tx, - &actual_gas_cost, - gas_sponsored, - storage_sponsored, - observer.tracer.map_or(Default::default(), |t| t.drain()), - &self.spec, - ), - )); - } else { - // From now on sender balance >= total_cost, even if the sender - // account does not exist (since she may be sponsored). Transaction - // execution is guaranteed. Note that inc_nonce() will create a - // new account if the account does not exist. - self.state.inc_nonce(&sender)?; - } - - // Subtract the transaction fee from sender or contract. - let gas_cost = U256::try_from(gas_cost).unwrap(); - // For tracer only when tx is sponsored. - let code_address = match tx.action() { - Action::Create => Address::zero(), - Action::Call(ref address) => *address, - }; - - if !gas_sponsored { - observer.as_state_tracer().trace_internal_transfer( - AddressPocket::Balance(sender.address.with_space(tx.space())), - AddressPocket::GasPayment, - gas_cost, - ); - self.state.sub_balance( - &sender, - &U256::try_from(gas_cost).unwrap(), - &mut cleanup_mode(&mut tx_substate, &spec), - )?; - // Don't subtract total_evm_balance here. It is maintained properly in - // `finalize`. - } else { - observer.as_state_tracer().trace_internal_transfer( - AddressPocket::SponsorBalanceForGas(code_address), - AddressPocket::GasPayment, - gas_cost, - ); - - self.state.sub_sponsor_balance_for_gas( - &code_address, - &U256::try_from(gas_cost).unwrap(), - )?; - } - - let init_gas = tx.gas() - base_gas_required; - - // Find the `storage_owner` in this execution. - let storage_owner = if storage_sponsored { - code_address - } else { - sender.address - }; - - // No matter who pays the collateral, we only focuses on the storage - // limit of sender. - let total_storage_limit = - self.state.collateral_for_storage(&sender.address)? + storage_cost; - - // Initialize the checkpoint for transaction execution. This checkpoint - // can be reverted by "deploying contract on conflict address" or "not - // enough balance for storage". - self.state.checkpoint(); - observer.as_state_tracer().checkpoint(); - let mut substate = Substate::new(); - - let res = match tx.action() { - Action::Create => { - let address_scheme = match tx.space() { - Space::Native => { - CreateContractAddress::FromSenderNonceAndCodeHash - } - Space::Ethereum => CreateContractAddress::FromSenderNonce, - }; - let (new_address, _code_hash) = contract_address( - address_scheme, - self.env.number.into(), - &sender, - &nonce, - &tx.data(), - ); - - // For a contract address already with code, we do not allow - // overlap the address. This should generally - // not happen. Unless we enable account dust in - // future. We add this check just in case it - // helps in future. - if sender.space == Space::Native - && self.state.is_contract_with_code(&new_address)? - { - observer.as_state_tracer().revert_to_checkpoint(); - self.state.revert_to_checkpoint(); - return Ok(ExecutionOutcome::ExecutionErrorBumpNonce( - ExecutionError::VmError(vm::Error::ConflictAddress( - new_address.address.clone(), - )), - Executed::execution_error_fully_charged( - tx, - gas_sponsored, - storage_sponsored, - observer - .tracer - .map_or(Default::default(), |t| t.drain()), - &spec, - ), - )); - } - - let params = ActionParams { - space: sender.space, - code_address: new_address.address, - code_hash: None, - address: new_address.address, - sender: sender.address, - original_sender: sender.address, - storage_owner, - gas: init_gas, - gas_price: *tx.gas_price(), - value: ActionValue::Transfer(*tx.value()), - code: Some(Arc::new(tx.data().clone())), - data: None, - call_type: CallType::None, - create_type: CreateType::CREATE, - params_type: vm::ParamsType::Embedded, - }; - self.create( - params, - &mut substate, - &mut *observer.as_vm_observe(), - )? - } - Action::Call(ref address) => { - let address = address.with_space(sender.space); - let params = ActionParams { - space: sender.space, - code_address: address.address, - address: address.address, - sender: sender.address, - original_sender: sender.address, - storage_owner, - gas: init_gas, - gas_price: *tx.gas_price(), - value: ActionValue::Transfer(*tx.value()), - code: self.state.code(&address)?, - code_hash: self.state.code_hash(&address)?, - data: Some(tx.data().clone()), - call_type: CallType::Call, - create_type: CreateType::None, - params_type: vm::ParamsType::Separate, - }; - self.call( - params, - &mut substate, - &mut *observer.as_vm_observe(), - )? - } - }; - - // Charge collateral and process the checkpoint. - let (result, output) = { - let res = res.and_then(|finalize_res| { - let dry_run = !matches!( - check_settings.charge_collateral, - ChargeCollateral::Normal - ); - - // For a ethereum space tx, this function has no op. - let mut res = settle_collateral_for_all( - &mut self.state, - &substate, - observer.as_state_tracer(), - &self.spec, - dry_run, - )?; - if res.ok() { - res = self.state.check_storage_limit( - &sender.address, - &total_storage_limit, - dry_run, - )?; - } - res.into_vm_result().and(Ok(finalize_res)) - }); - let out = match &res { - Ok(res) => { - observer.as_state_tracer().discard_checkpoint(); - self.state.discard_checkpoint(); - tx_substate.accrue(substate); - res.return_data.to_vec() - } - Err(vm::Error::StateDbError(_)) => { - // The whole epoch execution fails. No need to revert state. - Vec::new() - } - Err(_) => { - observer.as_state_tracer().revert_to_checkpoint(); - self.state.revert_to_checkpoint(); - Vec::new() - } - }; - (res, out) - }; - - let refund_receiver = if gas_sponsored { - Some(code_address) - } else { - None - }; - - let estimated_gas_limit = observer - .gas_man - .as_ref() - .map(|g| g.gas_required() * 7 / 6 + base_gas_required); - - Ok(self.finalize( - tx, - tx_substate, - result, - output, - refund_receiver, - /* Storage sponsor paid */ - if self.spec.cip78a { - storage_sponsored - } else { - storage_sponsor_eligible - }, - observer, - estimated_gas_limit, - )?) - } - - // TODO: maybe we can find a better interface for doing the suicide - // post-processing. - fn kill_process( - &mut self, suicides: &HashSet, - tracer: &mut dyn StateTracer, spec: &Spec, - ) -> DbResult - { - let mut substate = Substate::new(); - for address in suicides { - if let Some(code_size) = self.state.code_size(address)? { - // Only refund the code collateral when code exists. - // If a contract suicides during creation, the code will be - // empty. - if address.space == Space::Native { - let code_owner = self - .state - .code_owner(address)? - .expect("code owner exists"); - substate.record_storage_release( - &code_owner, - code_collateral_units(code_size), - ); - } - } - - if address.space == Space::Native { - self.state.record_storage_and_whitelist_entries_release( - &address.address, - &mut substate, - )?; - } - } - - let res = settle_collateral_for_all( - &mut self.state, - &substate, - tracer, - spec, - false, - )?; - // Kill process does not occupy new storage entries. - // The storage recycling process should never occupy new collateral. - assert_eq!(res, CollateralCheckResult::Valid); - - for contract_address in suicides - .iter() - .filter(|x| x.space == Space::Native) - .map(|x| &x.address) - { - let sponsor_for_gas = - self.state.sponsor_for_gas(contract_address)?; - let sponsor_for_collateral = - self.state.sponsor_for_collateral(contract_address)?; - let sponsor_balance_for_gas = - self.state.sponsor_balance_for_gas(contract_address)?; - let sponsor_balance_for_collateral = self - .state - .sponsor_balance_for_collateral(contract_address)?; - - if let Some(ref sponsor_address) = sponsor_for_gas { - tracer.trace_internal_transfer( - AddressPocket::SponsorBalanceForGas(*contract_address), - AddressPocket::Balance(sponsor_address.with_native_space()), - sponsor_balance_for_gas.clone(), - ); - self.state.add_balance( - &sponsor_address.with_native_space(), - &sponsor_balance_for_gas, - cleanup_mode(&mut substate, self.spec), - )?; - self.state.sub_sponsor_balance_for_gas( - contract_address, - &sponsor_balance_for_gas, - )?; - } - if let Some(ref sponsor_address) = sponsor_for_collateral { - tracer.trace_internal_transfer( - AddressPocket::SponsorBalanceForStorage(*contract_address), - AddressPocket::Balance(sponsor_address.with_native_space()), - sponsor_balance_for_collateral.clone(), - ); - - self.state.add_balance( - &sponsor_address.with_native_space(), - &sponsor_balance_for_collateral, - cleanup_mode(&mut substate, self.spec), - )?; - self.state.sub_sponsor_balance_for_collateral( - contract_address, - &sponsor_balance_for_collateral, - )?; - } - } - - for contract_address in suicides { - if contract_address.space == Space::Native { - let contract_address = contract_address.address; - let staking_balance = - self.state.staking_balance(&contract_address)?; - tracer.trace_internal_transfer( - AddressPocket::StakingBalance(contract_address), - AddressPocket::MintBurn, - staking_balance.clone(), - ); - self.state.sub_total_issued(staking_balance); - } - - let contract_balance = self.state.balance(contract_address)?; - tracer.trace_internal_transfer( - AddressPocket::Balance(*contract_address), - AddressPocket::MintBurn, - contract_balance.clone(), - ); - - self.state.remove_contract(contract_address)?; - self.state.sub_total_issued(contract_balance); - if contract_address.space == Space::Ethereum { - self.state.sub_total_evm_tokens(contract_balance); - } - } - - Ok(substate) - } - - /// Finalizes the transaction (does refunds and suicides). - fn finalize( - &mut self, tx: &SignedTransaction, mut substate: Substate, - result: vm::Result, output: Bytes, - refund_receiver: Option
, storage_sponsor_paid: bool, - mut observer: Observer, estimated_gas_limit: Option, - ) -> DbResult - { - let gas_left = match result { - Ok(FinalizationResult { gas_left, .. }) => gas_left, - _ => 0.into(), - }; - - // gas_used is only used to estimate gas needed - let gas_used = tx.gas() - gas_left; - // gas_left should be smaller than 1/4 of gas_limit, otherwise - // 3/4 of gas_limit is charged. - let charge_all = (gas_left + gas_left + gas_left) >= gas_used; - let (gas_charged, fees_value, refund_value) = if charge_all { - let gas_refunded = tx.gas() >> 2; - let gas_charged = tx.gas() - gas_refunded; - ( - gas_charged, - gas_charged.saturating_mul(*tx.gas_price()), - gas_refunded.saturating_mul(*tx.gas_price()), - ) - } else { - ( - gas_used, - gas_used.saturating_mul(*tx.gas_price()), - gas_left.saturating_mul(*tx.gas_price()), - ) - }; - - if let Some(r) = refund_receiver { - observer.as_state_tracer().trace_internal_transfer( - AddressPocket::GasPayment, - AddressPocket::SponsorBalanceForGas(r), - refund_value.clone(), - ); - self.state.add_sponsor_balance_for_gas(&r, &refund_value)?; - } else { - observer.as_state_tracer().trace_internal_transfer( - AddressPocket::GasPayment, - AddressPocket::Balance(tx.sender()), - refund_value.clone(), - ); - self.state.add_balance( - &tx.sender(), - &refund_value, - cleanup_mode(&mut substate, self.spec), - )?; - }; - - if tx.space() == Space::Ethereum { - self.state.sub_total_evm_tokens(fees_value); - } - - // perform suicides - - let subsubstate = self.kill_process( - &substate.suicides, - observer.as_state_tracer(), - &self.spec, - )?; - substate.accrue(subsubstate); - - // TODO should be added back after enabling dust collection - // Should be executed once per block, instead of per transaction? - // - // When enabling this feature, remember to check touched set in - // functions like "add_collateral_for_storage()" in "State" - // struct. - - // // perform garbage-collection - // let min_balance = if spec.kill_dust != CleanDustMode::Off { - // Some(U256::from(spec.tx_gas) * tx.gas_price()) - // } else { - // None - // }; - // - // self.state.kill_garbage( - // &substate.touched, - // spec.kill_empty, - // &min_balance, - // spec.kill_dust == CleanDustMode::WithCodeAndStorage, - // )?; - - match result { - Err(vm::Error::StateDbError(e)) => bail!(e.0), - Err(exception) => Ok(ExecutionOutcome::ExecutionErrorBumpNonce( - ExecutionError::VmError(exception), - Executed::execution_error_fully_charged( - tx, - refund_receiver.is_some(), - storage_sponsor_paid, - observer.tracer.map_or(Default::default(), |t| t.drain()), - &self.spec, - ), - )), - Ok(r) => { - let mut storage_collateralized = Vec::new(); - let mut storage_released = Vec::new(); - - if r.apply_state { - let mut affected_address: Vec<_> = substate - .keys_for_collateral_changed() - .iter() - .cloned() - .collect(); - affected_address.sort(); - for address in affected_address { - let (inc, sub) = - substate.get_collateral_change(&address); - if inc > 0 { - storage_collateralized.push(StorageChange { - address: *address, - collaterals: inc.into(), - }); - } else if sub > 0 { - storage_released.push(StorageChange { - address: *address, - collaterals: sub.into(), - }); - } - } - } - - let trace = - observer.tracer.map_or(Default::default(), |t| t.drain()); - - let estimated_storage_limit = - if let Some(x) = storage_collateralized.first() { - x.collaterals.as_u64() - } else { - 0 - }; - - let executed = Executed { - gas_used, - gas_charged, - fee: fees_value, - gas_sponsor_paid: refund_receiver.is_some(), - logs: substate.logs.to_vec(), - contracts_created: substate.contracts_created.to_vec(), - storage_sponsor_paid, - storage_collateralized, - storage_released, - output, - trace, - estimated_gas_limit, - estimated_storage_limit, - }; - - if r.apply_state { - Ok(ExecutionOutcome::Finished(executed)) - } else { - // Transaction reverted by vm instruction. - Ok(ExecutionOutcome::ExecutionErrorBumpNonce( - ExecutionError::VmError(vm::Error::Reverted), - executed, - )) - } - } - } - } -} diff --git a/core/src/executive/internal_contract/impls/cross_space.rs b/core/src/executive/internal_contract/impls/cross_space.rs deleted file mode 100644 index 7aaec7771a..0000000000 --- a/core/src/executive/internal_contract/impls/cross_space.rs +++ /dev/null @@ -1,667 +0,0 @@ -use crate::{ - evm::{ - ActionParams, CallType, Context, ContractCreateResult, - CreateContractAddress, GasLeft, MessageCallResult, ReturnData, - }, - executive::{contract_address, executive::gas_required_for}, - internal_bail, - observer::{AddressPocket, VmObserve}, - state::cleanup_mode, - vm::{ - self, ActionValue, CreateType, Exec, ExecTrapError as ExecTrap, - ExecTrapResult, ParamsType, ResumeCall, ResumeCreate, Spec, TrapResult, - }, -}; - -use cfx_parameters::{ - block::CROSS_SPACE_GAS_RATIO, - internal_contract_addresses::CROSS_SPACE_CONTRACT_ADDRESS, -}; -use cfx_statedb::Result as DbResult; -use cfx_types::{ - Address, AddressSpaceUtil, AddressWithSpace, Bloom, Space, H256, U256, -}; -use keccak_hash::keccak; -use primitives::{ - Action, Eip155Transaction, LogEntry, Receipt, SignedTransaction, - TransactionOutcome, -}; -use solidity_abi::{ABIDecodable, ABIEncodable}; -use std::{marker::PhantomData, sync::Arc}; - -use super::super::{ - components::{InternalRefContext, SolidityEventTrait}, - contracts::cross_space::{ - CallEvent, CreateEvent, ReturnEvent, WithdrawEvent, - }, -}; - -pub fn create_gas(context: &InternalRefContext, code: &[u8]) -> DbResult { - let code_length = code.len(); - - let transaction_gas = - gas_required_for(/* is_create */ true, code, context.spec) - + context.spec.tx_gas as u64; - - let create_gas = U256::from(context.spec.create_gas); - - let address_mapping_gas = context.spec.sha3_gas * 2; - - let create_log_gas = { - let log_data_length = - H256::len_bytes() * 4 + (code_length + 31) / 32 * 32; - context.spec.log_gas - + 3 * context.spec.log_topic_gas - + context.spec.log_data_gas * log_data_length - }; - - let return_log_gas = { - let log_data_length = H256::len_bytes(); - context.spec.log_gas - + context.spec.log_topic_gas - + context.spec.log_data_gas * log_data_length - }; - - Ok(create_gas - + transaction_gas - + address_mapping_gas - + create_log_gas - + return_log_gas) -} - -pub fn call_gas( - receiver: Address, params: &ActionParams, context: &InternalRefContext, - data: &[u8], -) -> DbResult -{ - let data_length = data.len(); - - let transaction_gas = - gas_required_for(/* is_create */ false, data, context.spec) - + context.spec.tx_gas as u64; - - let new_account = !context - .state - .exists_and_not_null(&receiver.with_evm_space())?; - let new_account_gas = if new_account { - context.spec.call_new_account_gas * context.spec.evm_gas_ratio - } else { - 0 - }; - - let transfer_gas = if params.value.value() > U256::zero() { - context.spec.call_value_transfer_gas - } else { - 0 - }; - - let call_gas = - U256::from(context.spec.call_gas) + new_account_gas + transfer_gas; - - let address_mapping_gas = context.spec.sha3_gas * 2; - - let call_log_gas = { - let log_data_length = - H256::len_bytes() * 4 + (data_length + 31) / 32 * 32; - context.spec.log_gas - + 3 * context.spec.log_topic_gas - + context.spec.log_data_gas * log_data_length - }; - - let return_log_gas = { - let log_data_length = H256::len_bytes(); - context.spec.log_gas - + context.spec.log_topic_gas - + context.spec.log_data_gas * log_data_length - }; - - Ok(call_gas - + transaction_gas - + address_mapping_gas - + call_log_gas - + return_log_gas) -} - -pub fn static_call_gas(spec: &Spec) -> U256 { - let call_gas = U256::from(spec.call_gas); - let address_mapping_gas = spec.sha3_gas * 2; - - call_gas + address_mapping_gas -} - -pub fn withdraw_gas(spec: &Spec) -> U256 { - let call_gas = U256::from(spec.call_value_transfer_gas); - let transaction_gas = spec.tx_gas; - let address_mapping_gas = spec.sha3_gas; - let log_gas = spec.log_gas - + spec.log_topic_gas * 3 - + spec.log_data_gas * H256::len_bytes() * 2; - - call_gas + transaction_gas + address_mapping_gas + log_gas -} - -#[derive(Clone)] -pub struct Resume { - pub params: ActionParams, - pub gas_retained: U256, - pub wait_return_log: bool, -} - -impl ResumeCreate for Resume { - fn resume_create( - self: Box, result: ContractCreateResult, - ) -> Box { - let wait_return_log = self.wait_return_log; - let pass_result = match result { - ContractCreateResult::Created(address, gas_left) => { - let encoded_output = address.address.0.abi_encode(); - let length = encoded_output.len(); - let return_data = ReturnData::new(encoded_output, 0, length); - PassResult { - resume: *self, - gas_left, - return_data: Ok(return_data), - apply_state: true, - wait_return_log, - } - } - ContractCreateResult::Failed(err) => PassResult { - resume: *self, - gas_left: U256::zero(), - return_data: Err(err), - apply_state: false, - wait_return_log, - }, - ContractCreateResult::Reverted(gas_left, data) => PassResult { - resume: *self, - gas_left, - return_data: Ok(data), - apply_state: false, - wait_return_log, - }, - }; - Box::new(pass_result) - } -} - -impl ResumeCall for Resume { - fn resume_call( - self: Box, result: MessageCallResult, - ) -> Box { - let wait_return_log = self.wait_return_log; - let pass_result = match result { - MessageCallResult::Success(gas_left, data) => { - let encoded_output = data.to_vec().abi_encode(); - let length = encoded_output.len(); - let return_data = ReturnData::new(encoded_output, 0, length); - PassResult { - resume: *self, - gas_left, - return_data: Ok(return_data), - apply_state: true, - wait_return_log, - } - } - MessageCallResult::Failed(err) => PassResult { - resume: *self, - gas_left: U256::zero(), - return_data: Err(err), - apply_state: false, - wait_return_log, - }, - MessageCallResult::Reverted(gas_left, data) => PassResult { - resume: *self, - gas_left, - return_data: Ok(data), - apply_state: false, - wait_return_log, - }, - }; - Box::new(pass_result) - } -} - -pub struct PassResult { - resume: Resume, - gas_left: U256, - return_data: Result, - apply_state: bool, - wait_return_log: bool, -} - -impl Exec for PassResult { - fn exec( - mut self: Box, context: &mut dyn Context, - _tracer: &mut dyn VmObserve, - ) -> ExecTrapResult - { - let context = &mut context.internal_ref(); - - if self.wait_return_log { - ReturnEvent::log( - &(), - &self.apply_state, - &self.resume.params, - context, - ) - .expect("Must have no static flag"); - } - - let mut gas_returned = U256::zero(); - if let Ok(ref data) = self.return_data { - let length = data.len(); - let return_cost = - U256::from((length + 31) / 32 * context.spec.memory_gas); - let gas_left = self.gas_left + self.resume.gas_retained; - if gas_left < return_cost { - gas_returned = U256::zero(); - self.return_data = Err(vm::Error::OutOfGas); - self.apply_state = false; - } else { - gas_returned = gas_left - return_cost; - } - } - - let result = match self.return_data { - Ok(data) => Ok(GasLeft::NeedsReturn { - gas_left: gas_returned, - data, - apply_state: self.apply_state, - }), - Err(err) => Err(err), - }; - TrapResult::Return(result) - } -} - -pub fn evm_map(address: Address) -> AddressWithSpace { - Address::from(keccak(&address)).with_evm_space() -} - -pub fn process_trap( - result: Result, _phantom: PhantomData, -) -> ExecTrapResult { - match result { - Ok(trap) => TrapResult::SubCallCreate(trap), - Err(err) => TrapResult::Return(Err(err)), - } -} - -pub fn call_to_evmcore( - receiver: Address, data: Vec, call_type: CallType, - params: &ActionParams, gas_left: U256, context: &mut InternalRefContext, - tracer: &mut dyn VmObserve, -) -> Result -{ - if context.depth >= context.spec.max_depth { - internal_bail!("Exceed Depth"); - } - - let value = params.value.value(); - - let call_gas = gas_left / CROSS_SPACE_GAS_RATIO - + if value > U256::zero() { - U256::from(context.spec.call_stipend) - } else { - U256::zero() - }; - let reserved_gas = gas_left - gas_left / CROSS_SPACE_GAS_RATIO; - - let mapped_sender = evm_map(params.sender); - let mapped_origin = evm_map(params.original_sender); - - context.state.transfer_balance( - ¶ms.address.with_native_space(), - &mapped_sender, - &value, - cleanup_mode(context.substate, context.spec), - )?; - context.state.add_total_evm_tokens(value); - tracer.trace_internal_transfer( - AddressPocket::Balance(params.address.with_native_space()), - AddressPocket::Balance(mapped_sender), - params.value.value(), - ); - - let address = receiver.with_evm_space(); - - let code = context.state.code(&address)?; - let code_hash = context.state.code_hash(&address)?; - - let next_params = ActionParams { - space: Space::Ethereum, - sender: mapped_sender.address, - address: address.address, - value: ActionValue::Transfer(value), - code_address: address.address, - original_sender: mapped_origin.address, - storage_owner: mapped_sender.address, - gas: call_gas, - gas_price: params.gas_price, - code, - code_hash, - data: Some(data.clone()), - call_type, - create_type: CreateType::None, - params_type: vm::ParamsType::Separate, - }; - - let mut wait_return_log = false; - - if call_type == CallType::Call { - let nonce = context.state.nonce(&mapped_sender)?; - context.state.inc_nonce(&mapped_sender)?; - CallEvent::log( - &(mapped_sender.address.0, address.address.0), - &(value, nonce, data), - params, - context, - )?; - wait_return_log = true; - } - - return Ok(ExecTrap::Call( - next_params, - Box::new(Resume { - params: params.clone(), - gas_retained: reserved_gas, - wait_return_log, - }), - )); -} - -pub fn create_to_evmcore( - init: Vec, salt: Option, params: &ActionParams, gas_left: U256, - context: &mut InternalRefContext, tracer: &mut dyn VmObserve, -) -> Result -{ - if context.depth >= context.spec.max_depth { - internal_bail!("Exceed Depth"); - } - - let call_gas = gas_left / CROSS_SPACE_GAS_RATIO - + if params.value.value() > U256::zero() { - U256::from(context.spec.call_stipend) - } else { - U256::zero() - }; - let reserved_gas = gas_left - gas_left / CROSS_SPACE_GAS_RATIO; - - let mapped_sender = evm_map(params.sender); - let mapped_origin = evm_map(params.original_sender); - - let value = params.value.value(); - context.state.transfer_balance( - ¶ms.address.with_native_space(), - &mapped_sender, - &value, - cleanup_mode(context.substate, context.spec), - )?; - context.state.add_total_evm_tokens(value); - tracer.trace_internal_transfer( - AddressPocket::Balance(params.address.with_native_space()), - AddressPocket::Balance(mapped_sender), - params.value.value(), - ); - - let (address_scheme, create_type) = match salt { - None => (CreateContractAddress::FromSenderNonce, CreateType::CREATE), - Some(salt) => ( - CreateContractAddress::FromSenderSaltAndCodeHash(salt), - CreateType::CREATE2, - ), - }; - let (address_with_space, code_hash) = contract_address( - address_scheme, - context.env.number.into(), - &mapped_sender, - &context.state.nonce(&mapped_sender)?, - &init, - ); - let address = address_with_space.address; - - let next_params = ActionParams { - space: Space::Ethereum, - code_address: address, - address, - sender: mapped_sender.address, - original_sender: mapped_origin.address, - storage_owner: Address::zero(), - gas: call_gas, - gas_price: params.gas_price, - value: ActionValue::Transfer(value), - code: Some(Arc::new(init.clone())), - code_hash, - data: None, - call_type: CallType::None, - create_type, - params_type: ParamsType::Embedded, - }; - - let nonce = context.state.nonce(&mapped_sender)?; - context.state.inc_nonce(&mapped_sender)?; - CreateEvent::log( - &(mapped_sender.address.0, address.0), - &(value, nonce, init), - params, - context, - )?; - - return Ok(ExecTrap::Create( - next_params, - Box::new(Resume { - params: params.clone(), - gas_retained: reserved_gas, - wait_return_log: true, - }), - )); -} - -pub fn withdraw_from_evmcore( - sender: Address, value: U256, params: &ActionParams, - context: &mut InternalRefContext, tracer: &mut dyn VmObserve, -) -> vm::Result<()> -{ - let mapped_address = evm_map(sender); - let balance = context.state.balance(&mapped_address)?; - if balance < value { - internal_bail!( - "Not enough balance for withdrawing from mapped address" - ); - } - context.state.transfer_balance( - &mapped_address, - &sender.with_native_space(), - &value, - cleanup_mode(context.substate, context.spec), - )?; - context.state.sub_total_evm_tokens(value); - tracer.trace_internal_transfer( - AddressPocket::Balance(mapped_address), - AddressPocket::Balance(sender.with_native_space()), - value, - ); - - let nonce = context.state.nonce(&mapped_address)?; - context.state.inc_nonce(&mapped_address)?; - WithdrawEvent::log( - &(mapped_address.address.0, sender), - &(value, nonce), - params, - context, - )?; - - Ok(()) -} - -pub fn mapped_balance( - address: Address, context: &mut InternalRefContext, -) -> vm::Result { - Ok(context.state.balance(&evm_map(address))?) -} - -pub fn mapped_nonce( - address: Address, context: &mut InternalRefContext, -) -> vm::Result { - Ok(context.state.nonce(&evm_map(address))?) -} - -#[derive(Clone, Debug, Default)] -pub struct PhantomTransaction { - pub from: Address, - pub nonce: U256, - pub action: Action, - pub value: U256, - pub data: Vec, - - pub log_bloom: Bloom, - pub logs: Vec, - pub outcome_status: TransactionOutcome, -} - -impl PhantomTransaction { - fn simple_transfer( - from: Address, to: Address, nonce: U256, value: U256, data: Vec, - ) -> PhantomTransaction { - PhantomTransaction { - from, - nonce, - action: Action::Call(to), - value, - data, - outcome_status: TransactionOutcome::Success, - ..Default::default() - } - } -} - -impl PhantomTransaction { - pub fn into_eip155(self, chain_id: u32) -> SignedTransaction { - let tx = Eip155Transaction { - action: self.action, - chain_id: Some(chain_id), - data: self.data, - gas_price: 0.into(), - gas: 0.into(), - nonce: self.nonce, - value: self.value, - }; - - tx.fake_sign_phantom(self.from.with_space(Space::Ethereum)) - } - - pub fn into_receipt(self, accumulated_gas_used: U256) -> Receipt { - Receipt { - accumulated_gas_used, - gas_fee: 0.into(), - gas_sponsor_paid: false, - log_bloom: self.log_bloom, - logs: self.logs, - outcome_status: self.outcome_status, - storage_collateralized: vec![], - storage_released: vec![], - storage_sponsor_paid: false, - } - } -} - -type Bytes20 = [u8; 20]; - -pub fn build_bloom_and_recover_phantom( - logs: &[LogEntry], tx_hash: H256, -) -> (Vec, Bloom) { - let mut phantom_txs: Vec = Default::default(); - let mut maybe_working_tx: Option = None; - let mut all_bloom = Bloom::default(); - let mut cross_space_nonce = 0u32; - for log in logs.iter() { - let log_bloom = log.bloom(); - all_bloom.accrue_bloom(&log_bloom); - if log.address == CROSS_SPACE_CONTRACT_ADDRESS { - let event_sig = log.topics.first().unwrap(); - if event_sig == &CallEvent::EVENT_SIG - || event_sig == &CreateEvent::EVENT_SIG - { - assert!(maybe_working_tx.is_none()); - - let from = Address::from( - Bytes20::abi_decode(&log.topics[1].as_ref()).unwrap(), - ); - let to = Address::from( - Bytes20::abi_decode(&log.topics[2].as_ref()).unwrap(), - ); - let (value, nonce, data): (_, _, Vec) = - ABIDecodable::abi_decode(&log.data).unwrap(); - - let is_create = event_sig == &CreateEvent::EVENT_SIG; - let action = if is_create { - Action::Create - } else { - Action::Call(to) - }; - // The first phantom transaction for cross-space call, transfer - // balance and gas fee from the zero address to the mapped - // sender - phantom_txs.push(PhantomTransaction::simple_transfer( - /* from */ Address::zero(), - /* to */ from, - U256::zero(), // Zero address always has nonce 0. - value, - /* data */ - (tx_hash, U256::from(cross_space_nonce)).abi_encode(), - )); - cross_space_nonce += 1; - // The second phantom transaction for cross-space call, transfer - // balance and gas fee from the zero address to the mapped - // sender - maybe_working_tx = Some(PhantomTransaction { - from, - nonce, - action, - value, - data, - ..Default::default() - }); - } else if event_sig == &WithdrawEvent::EVENT_SIG { - let from = Address::from( - Bytes20::abi_decode(&log.topics[1].as_ref()).unwrap(), - ); - let (value, nonce) = - ABIDecodable::abi_decode(&log.data).unwrap(); - // The only one transaction for the withdraw - phantom_txs.push(PhantomTransaction::simple_transfer( - from, - Address::zero(), - nonce, - value, - /* data */ vec![], - )); - } else if event_sig == &ReturnEvent::EVENT_SIG { - let success: bool = - ABIDecodable::abi_decode(&log.data).unwrap(); - - let mut working_tx = - std::mem::take(&mut maybe_working_tx).unwrap(); - - working_tx.outcome_status = if success { - TransactionOutcome::Success - } else { - TransactionOutcome::Failure - }; - - // Complete the second transaction for cross-space call. - phantom_txs.push(working_tx); - } - } else if log.space == Space::Ethereum { - if let Some(ref mut working_tx) = maybe_working_tx { - // The receipt is generated in cross-space call - working_tx.logs.push(log.clone()); - working_tx.log_bloom.accrue_bloom(&log_bloom); - } else { - // The receipt is generated in evm-space transaction. Does - // nothing. - } - } - } - return (phantom_txs, all_bloom); -} diff --git a/core/src/executive/mod.rs b/core/src/executive/mod.rs deleted file mode 100644 index 7d9dde764c..0000000000 --- a/core/src/executive/mod.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2019 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -mod context; -mod executed; -mod executive; -#[cfg(test)] -mod executive_tests; -pub mod internal_contract; -mod vm_exec; - -trait CollateralCheckResultToVmResult { - fn into_vm_result(self) -> Result<(), vmError>; -} - -impl CollateralCheckResultToVmResult for CollateralCheckResult { - fn into_vm_result(self) -> Result<(), vmError> { - match self { - CollateralCheckResult::ExceedStorageLimit { .. } => { - Err(vmError::ExceedStorageLimit) - } - CollateralCheckResult::NotEnoughBalance { required, got } => { - Err(vmError::NotEnoughBalanceForStorage { required, got }) - } - CollateralCheckResult::Valid => Ok(()), - } - } -} - -pub use self::{ - executed::*, - executive::{ - contract_address, gas_required_for, EstimateRequest, Executive, - ExecutiveGeneric, ExecutiveResult, Observer, TransactCheckSettings, - TransactOptions, - }, - internal_contract::{InternalContractMap, InternalContractTrait}, -}; -use crate::vm::Error as vmError; -use cfx_state::CollateralCheckResult; diff --git a/core/src/executive/vm_exec.rs b/core/src/executive/vm_exec.rs deleted file mode 100644 index c3cf982ea8..0000000000 --- a/core/src/executive/vm_exec.rs +++ /dev/null @@ -1,103 +0,0 @@ -use crate::{ - builtin::Builtin, - evm::{CallType, Context, GasLeft, MessageCallResult, ReturnData}, - executive::InternalContractTrait, - observer::VmObserve, - vm::{ - ActionParams, Error as VmError, Exec, ExecTrapResult, ResumeCall, - TrapResult, - }, -}; -use cfx_bytes::BytesRef; -use cfx_types::U256; - -pub struct NoopExec { - pub gas: U256, -} - -impl Exec for NoopExec { - fn exec( - self: Box, _: &mut dyn Context, _: &mut dyn VmObserve, - ) -> ExecTrapResult { - TrapResult::Return(Ok(GasLeft::Known(self.gas))) - } -} -pub struct BuiltinExec<'a> { - pub builtin: &'a Builtin, - pub params: ActionParams, -} - -impl<'a> Exec for BuiltinExec<'a> { - // Copied from exec function of CallCreateExecutive. - fn exec( - self: Box, _: &mut dyn Context, _: &mut dyn VmObserve, - ) -> ExecTrapResult { - let default = []; - let data = if let Some(ref d) = self.params.data { - d as &[u8] - } else { - &default as &[u8] - }; - - let cost = self.builtin.cost(data); - let output = if cost <= self.params.gas { - let mut builtin_out_buffer = Vec::new(); - let result = { - let mut builtin_output = - BytesRef::Flexible(&mut builtin_out_buffer); - self.builtin.execute(data, &mut builtin_output) - }; - match result { - Ok(_) => { - let out_len = builtin_out_buffer.len(); - Ok(GasLeft::NeedsReturn { - gas_left: self.params.gas - cost, - data: ReturnData::new(builtin_out_buffer, 0, out_len), - apply_state: true, - }) - } - Err(e) => Err(e.into()), - } - } else { - Err(VmError::OutOfGas) - }; - TrapResult::Return(output) - } -} - -pub struct InternalContractExec<'a> { - pub internal: &'a Box, - pub params: ActionParams, -} - -impl<'a> Exec for InternalContractExec<'a> { - fn exec( - self: Box, context: &mut dyn Context, tracer: &mut dyn VmObserve, - ) -> ExecTrapResult { - let result = if self.params.call_type != CallType::Call - && self.params.call_type != CallType::StaticCall - { - TrapResult::Return(Err(VmError::InternalContract( - "Incorrect call type.".into(), - ))) - } else { - let mut context = context.internal_ref(); - self.internal.execute(&self.params, &mut context, tracer) - }; - if let TrapResult::Return(ref vm_result) = result { - debug!("Internal Call Result: {:?}", vm_result); - } else { - debug!("Internal Call Has a sub-call/create"); - } - - result - } -} - -impl<'a> ResumeCall for InternalContractExec<'a> { - fn resume_call( - self: Box, _result: MessageCallResult, - ) -> Box { - todo!() - } -} diff --git a/core/src/observer/mod.rs b/core/src/observer/mod.rs deleted file mode 100644 index 9bf68f68bd..0000000000 --- a/core/src/observer/mod.rs +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2020 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -use crate::{ - executive::ExecutiveResult, - vm::{ActionParams, Result as VmResult}, -}; -pub use cfx_state::tracer::{AddressPocket, StateTracer}; - -pub mod error_unwind; -pub mod gasman; -pub mod trace; -pub mod trace_filter; -pub mod tracer; - -pub use error_unwind::ErrorUnwind; -pub use gasman::GasMan; -pub use tracer::ExecutiveTracer; - -// FIXME(cx): Can the observer do not rely on the tracer? -/// This trait is used by executive to build traces. -pub trait VmObserve: StateTracer { - /// Prepares call trace for given params. - fn record_call(&mut self, params: &ActionParams); - - /// Prepares call result trace - fn record_call_result(&mut self, result: &VmResult); - - /// Prepares create trace for given params. - fn record_create(&mut self, params: &ActionParams); - - /// Prepares create result trace - fn record_create_result(&mut self, result: &VmResult); -} - -/// Nonoperative observer. Does not trace anything. -impl VmObserve for () { - fn record_call(&mut self, _: &ActionParams) {} - - fn record_call_result(&mut self, _: &VmResult) {} - - fn record_create(&mut self, _: &ActionParams) {} - - fn record_create_result(&mut self, _: &VmResult) {} -} - -impl VmObserve for &mut T -where T: VmObserve -{ - fn record_call(&mut self, params: &ActionParams) { - (*self).record_call(params); - } - - fn record_call_result(&mut self, result: &VmResult) { - (*self).record_call_result(result); - } - - fn record_create(&mut self, params: &ActionParams) { - (*self).record_create(params); - } - - fn record_create_result(&mut self, result: &VmResult) { - (*self).record_create_result(result); - } -} - -impl VmObserve for (&mut S, &mut T) -where - S: VmObserve, - T: VmObserve, -{ - fn record_call(&mut self, params: &ActionParams) { - self.0.record_call(params); - self.1.record_call(params); - } - - fn record_call_result(&mut self, result: &VmResult) { - self.0.record_call_result(result); - self.1.record_call_result(result); - } - - fn record_create(&mut self, params: &ActionParams) { - self.0.record_create(params); - self.1.record_create(params); - } - - fn record_create_result(&mut self, result: &VmResult) { - self.0.record_create_result(result); - self.1.record_create_result(result); - } -} diff --git a/core/src/observer/trace.rs b/core/src/observer/trace.rs deleted file mode 100644 index fd645dfe60..0000000000 --- a/core/src/observer/trace.rs +++ /dev/null @@ -1,1003 +0,0 @@ -// Copyright 2020 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -use super::AddressPocket; -use crate::{ - bytes::Bytes, - executive::{ - internal_contract::{is_call_create_sig, is_withdraw_sig}, - ExecutiveResult, - }, - observer::trace_filter::TraceFilter, - vm::{ActionParams, CallType, CreateType, Result as vmResult}, -}; -use cfx_internal_common::{DatabaseDecodable, DatabaseEncodable}; -use cfx_parameters::internal_contract_addresses::CROSS_SPACE_CONTRACT_ADDRESS; -use cfx_types::{ - Address, AddressWithSpace, Bloom, BloomInput, Space, H256, U256, U64, -}; -use malloc_size_of_derive::MallocSizeOf; -use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; -use rlp_derive::{RlpDecodable, RlpEncodable}; -use serde::{ser::SerializeStruct, Serialize, Serializer}; -use solidity_abi::ABIEncodable; -use strum_macros::EnumDiscriminants; - -/// Description of a _call_ action, either a `CALL` operation or a message -/// transaction. -#[derive(Debug, Clone, PartialEq, RlpEncodable, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Call { - /// The space - pub space: Space, - /// The sending account. - pub from: Address, - /// The destination account. - pub to: Address, - /// The value transferred to the destination account. - pub value: U256, - /// The gas available for executing the call. - pub gas: U256, - /// The input data provided to the call. - pub input: Bytes, - /// The type of the call. - pub call_type: CallType, -} - -impl Decodable for Call { - fn decode(rlp: &Rlp) -> Result { - match rlp.item_count()? { - 6 => Ok(Call { - space: Space::Native, - from: rlp.val_at(0)?, - to: rlp.val_at(1)?, - value: rlp.val_at(2)?, - gas: rlp.val_at(3)?, - input: rlp.val_at(4)?, - call_type: rlp.val_at(5)?, - }), - 7 => Ok(Call { - space: rlp.val_at(0)?, - from: rlp.val_at(1)?, - to: rlp.val_at(2)?, - value: rlp.val_at(3)?, - gas: rlp.val_at(4)?, - input: rlp.val_at(5)?, - call_type: rlp.val_at(6)?, - }), - _ => Err(DecoderError::RlpInvalidLength), - } - } -} - -impl From for Call { - fn from(p: ActionParams) -> Self { - match p.call_type { - CallType::DelegateCall | CallType::CallCode => Call { - space: p.space, - from: p.address, - to: p.code_address, - value: p.value.value(), - gas: p.gas, - input: p.data.unwrap_or_else(Vec::new), - call_type: p.call_type, - }, - _ => Call { - space: p.space, - from: p.sender, - to: p.address, - value: p.value.value(), - gas: p.gas, - input: p.data.unwrap_or_else(Vec::new), - call_type: p.call_type, - }, - } - } -} - -impl Call { - /// Returns call action bloom. - /// The bloom contains from and to addresses. - pub fn bloom(&self) -> Bloom { - let mut bloom = Bloom::default(); - bloom.accrue(BloomInput::Raw(self.from.as_bytes())); - bloom.accrue(BloomInput::Raw(self.to.as_bytes())); - bloom - } -} - -/// The outcome of the action result. -#[derive(Debug, PartialEq, Clone, Serialize)] -#[serde(rename_all = "lowercase")] -pub enum Outcome { - Success, - Reverted, - Fail, -} - -impl Encodable for Outcome { - fn rlp_append(&self, s: &mut RlpStream) { - let v = match *self { - Outcome::Success => 0u32, - Outcome::Reverted => 1, - Outcome::Fail => 2, - }; - Encodable::rlp_append(&v, s); - } -} - -impl Decodable for Outcome { - fn decode(rlp: &Rlp) -> Result { - rlp.as_val().and_then(|v| { - Ok(match v { - 0u32 => Outcome::Success, - 1 => Outcome::Reverted, - 2 => Outcome::Fail, - _ => { - return Err(DecoderError::Custom( - "Invalid value of CallType item", - )); - } - }) - }) - } -} - -/// Description of the result of a _call_ action. -#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct CallResult { - /// The outcome of the result - pub outcome: Outcome, - /// The amount of gas left - pub gas_left: U256, - /// Output data - pub return_data: Bytes, -} - -impl From<&vmResult> for CallResult { - fn from(r: &vmResult) -> Self { - match r { - Ok(ExecutiveResult { - gas_left, - return_data, - apply_state: true, - .. - }) => CallResult { - outcome: Outcome::Success, - gas_left: gas_left.clone(), - return_data: return_data.to_vec(), - }, - Ok(ExecutiveResult { - gas_left, - return_data, - apply_state: false, - .. - }) => CallResult { - outcome: Outcome::Reverted, - gas_left: gas_left.clone(), - return_data: return_data.to_vec(), - }, - Err(err) => CallResult { - outcome: Outcome::Fail, - gas_left: U256::zero(), - return_data: format!("{:?}", err).into(), - }, - } - } -} - -/// Description of a _create_ action, either a `CREATE` operation or a create -/// transaction. -#[derive(Debug, Clone, PartialEq, RlpEncodable, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Create { - /// Space - pub space: Space, - /// The address of the creator. - pub from: Address, - /// The value with which the new account is endowed. - pub value: U256, - /// The gas available for the creation init code. - pub gas: U256, - /// The init code. - pub init: Bytes, - /// The create type `CREATE` or `CREATE2` - pub create_type: CreateType, -} - -impl Decodable for Create { - fn decode(rlp: &Rlp) -> Result { - match rlp.item_count()? { - 5 => Ok(Create { - space: Space::Native, - from: rlp.val_at(0)?, - value: rlp.val_at(1)?, - gas: rlp.val_at(2)?, - init: rlp.val_at(3)?, - create_type: rlp.val_at(4)?, - }), - 6 => Ok(Create { - space: rlp.val_at(0)?, - from: rlp.val_at(1)?, - value: rlp.val_at(2)?, - gas: rlp.val_at(3)?, - init: rlp.val_at(4)?, - create_type: rlp.val_at(5)?, - }), - _ => Err(DecoderError::RlpInvalidLength), - } - } -} - -impl From for Create { - fn from(p: ActionParams) -> Self { - Create { - space: p.space, - from: p.sender, - value: p.value.value(), - gas: p.gas, - init: p.code.map_or_else(Vec::new, |c| (*c).clone()), - create_type: p.create_type, - } - } -} - -impl Create { - /// Returns bloom create action bloom. - /// The bloom contains only from address. - pub fn bloom(&self) -> Bloom { - BloomInput::Raw(self.from.as_bytes()).into() - } -} - -/// Description of the result of a _create_ action. -#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct CreateResult { - /// The outcome of the create - pub outcome: Outcome, - /// The created contract address - pub addr: Address, - /// The amount of gas left - pub gas_left: U256, - /// Output data - pub return_data: Bytes, -} - -impl From<&vmResult> for CreateResult { - fn from(r: &vmResult) -> Self { - match r { - Ok(ExecutiveResult { - gas_left, - return_data, - apply_state: true, - create_address, - .. - }) => CreateResult { - outcome: Outcome::Success, - addr: create_address.expect( - "Address should not be none in executive result of create", - ), - gas_left: gas_left.clone(), - return_data: return_data.to_vec(), - }, - Ok(ExecutiveResult { - gas_left, - return_data, - apply_state: false, - .. - }) => CreateResult { - outcome: Outcome::Reverted, - addr: Address::zero(), - gas_left: gas_left.clone(), - return_data: return_data.to_vec(), - }, - Err(err) => CreateResult { - outcome: Outcome::Fail, - addr: Address::zero(), - gas_left: U256::zero(), - return_data: format!("{:?}", err).into(), - }, - } - } -} - -impl CreateResult { - /// Returns create result bloom. - /// The bloom contains only created contract address. - pub fn bloom(&self) -> Bloom { - if self.outcome == Outcome::Success { - BloomInput::Raw(self.addr.as_bytes()).into() - } else { - Bloom::default() - } - } -} - -/// Description of the result of an internal transfer action regarding about -/// CFX. -#[derive(Debug, Clone, PartialEq, RlpEncodable, RlpDecodable)] -pub struct InternalTransferAction { - /// The source address. If it is zero, then it is an interest mint action. - pub from: AddressPocket, - /// The destination address. If it is zero, then it is a burnt action. - pub to: AddressPocket, - /// The amount of CFX - pub value: U256, -} - -impl Serialize for InternalTransferAction { - fn serialize(&self, serializer: S) -> Result - where S: Serializer { - let mut s = serializer.serialize_struct("InternalTransferAction", 5)?; - s.serialize_field("from", &self.from.inner_address_or_default())?; - s.serialize_field("fromPocket", &*self.from.pocket())?; - s.serialize_field("fromSpace", &*self.from.space())?; - s.serialize_field("to", &self.to.inner_address_or_default())?; - s.serialize_field("toPocket", &*self.to.pocket())?; - s.serialize_field("toSpace", &*self.to.space())?; - s.serialize_field("value", &self.value)?; - s.end() - } -} - -impl InternalTransferAction { - pub fn bloom(&self) -> Bloom { - let mut bloom = Bloom::default(); - bloom.accrue(BloomInput::Raw( - self.from.inner_address_or_default().as_ref(), - )); - bloom.accrue(BloomInput::Raw( - self.to.inner_address_or_default().as_ref(), - )); - bloom - } -} - -/// Description of an action that we trace; will be either a call or a create. -#[derive(Debug, Clone, PartialEq, EnumDiscriminants)] -#[strum_discriminants(name(ActionType))] -pub enum Action { - /// It's a call action. - Call(Call), - /// It's a create action. - Create(Create), - /// It's the result of a call action - CallResult(CallResult), - /// It's the result of a create action - CreateResult(CreateResult), - /// It's an internal transfer action - InternalTransferAction(InternalTransferAction), -} - -impl Encodable for Action { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(2); - match *self { - Action::Call(ref call) => { - s.append(&0u8); - s.append(call); - } - Action::Create(ref create) => { - s.append(&1u8); - s.append(create); - } - Action::CallResult(ref call_result) => { - s.append(&2u8); - s.append(call_result); - } - Action::CreateResult(ref create_result) => { - s.append(&3u8); - s.append(create_result); - } - Action::InternalTransferAction(ref internal_action) => { - s.append(&4u8); - s.append(internal_action); - } - } - } -} - -impl Decodable for Action { - fn decode(rlp: &Rlp) -> Result { - let action_type: u8 = rlp.val_at(0)?; - match action_type { - 0 => rlp.val_at(1).map(Action::Call), - 1 => rlp.val_at(1).map(Action::Create), - 2 => rlp.val_at(1).map(Action::CallResult), - 3 => rlp.val_at(1).map(Action::CreateResult), - 4 => rlp.val_at(1).map(Action::InternalTransferAction), - _ => Err(DecoderError::Custom("Invalid action type.")), - } - } -} - -impl Action { - /// Returns action bloom. - pub fn bloom(&self) -> Bloom { - match *self { - Action::Call(ref call) => call.bloom(), - Action::Create(ref create) => create.bloom(), - Action::CallResult(_) => Bloom::default(), - Action::CreateResult(ref create_result) => create_result.bloom(), - Action::InternalTransferAction(ref internal_action) => { - internal_action.bloom() - } - } - } -} - -/// Trace localized in vector of traces produced by a single transaction. -/// -/// Parent and children indexes refer to positions in this vector. -#[derive(Debug, PartialEq, Clone, MallocSizeOf)] -pub struct ExecTrace { - #[ignore_malloc_size_of = "ignored for performance reason"] - /// Type of action performed by a transaction. - pub action: Action, - pub valid: bool, -} - -impl ExecTrace { - /// Returns bloom of the trace. - pub fn bloom(&self) -> Bloom { self.action.bloom() } -} - -impl Encodable for ExecTrace { - fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(2); - s.append(&self.action); - s.append(&self.valid); - } -} - -impl Decodable for ExecTrace { - fn decode(d: &Rlp) -> Result { - match d.item_count()? { - 1 => Ok(ExecTrace { - action: d.val_at(0)?, - valid: true, - }), - 2 => Ok(ExecTrace { - action: d.val_at(0)?, - valid: d.val_at(1)?, - }), - _ => Err(DecoderError::RlpInvalidLength), - } - } -} - -pub struct LocalizedTrace { - pub action: Action, - pub valid: bool, - /// Epoch hash. - pub epoch_hash: H256, - /// Epoch number. - pub epoch_number: U256, - /// Block hash. - pub block_hash: H256, - /// Transaction position. - pub transaction_position: U64, - /// Signed transaction hash. - pub transaction_hash: H256, -} - -/// Represents all traces produced by a single transaction. -#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable, MallocSizeOf)] -pub struct TransactionExecTraces(pub Vec); - -impl From> for TransactionExecTraces { - fn from(v: Vec) -> Self { TransactionExecTraces(v) } -} - -impl TransactionExecTraces { - /// Returns bloom of all traces in the collection. - pub fn bloom(&self) -> Bloom { - self.0 - .iter() - .fold(Default::default(), |bloom, trace| bloom | trace.bloom()) - } - - /// Return pairs of (action, result, subtrace_len). - /// Return `Err` if actions and results do not match. - /// - /// `from_address`, `to_address`, `action_types`, and `space` in `filter` - /// are applied. - pub fn filter_trace_pairs( - self, filter: &TraceFilter, - ) -> Result, String> { - let mut trace_pairs: Vec<(ExecTrace, Option, usize)> = - Vec::new(); - let mut stack_index = Vec::new(); - let mut sublen_stack = Vec::new(); - for trace in self.0 { - match &trace.action { - Action::Call(call) => { - if call.space == filter.space { - if let Some(parent_subtraces) = sublen_stack.last_mut() - { - *parent_subtraces += 1; - } - } - sublen_stack.push(0); - if call.space == filter.space - && filter.from_address.matches(&call.from) - && filter.to_address.matches(&call.to) - && filter.action_types.matches(&ActionType::Call) - { - stack_index.push(Some(trace_pairs.len())); - trace_pairs.push((trace, None, 0)); - } else { - // The corresponding result should be ignored. - stack_index.push(None); - } - } - Action::Create(create) => { - if create.space == filter.space { - if let Some(parent_subtraces) = sublen_stack.last_mut() - { - *parent_subtraces += 1; - } - } - sublen_stack.push(0); - if create.space == filter.space - && filter.from_address.matches(&create.from) - // TODO(lpl): openethereum uses `to_address` to filter the contract address. - && filter.action_types.matches(&ActionType::Create) - { - stack_index.push(Some(trace_pairs.len())); - trace_pairs.push((trace, None, 0)); - } else { - // The corresponding result should be ignored. - stack_index.push(None); - } - } - Action::CallResult(_) | Action::CreateResult(_) => { - if let Some(index) = stack_index - .pop() - .ok_or("result left unmatched!".to_string())? - { - // Since we know that traces should be paired correctly, - // we do not check if the type - // is correct here. - trace_pairs[index].1 = Some(trace); - let subtraces = - sublen_stack.pop().expect("stack_index matches"); - trace_pairs[index].2 = subtraces; - } else { - sublen_stack.pop(); - } - } - Action::InternalTransferAction(_) => {} - } - } - if !stack_index.is_empty() { - bail!("actions left unmatched!".to_string()); - } - Ok(trace_pairs - .into_iter() - .map(|pair| (pair.0, pair.1.expect("all actions matched"), pair.2)) - .collect()) - } - - /// Return filtered Native actions with their orders kept. - /// - /// `from_address`, `to_address`, `action_types`, and `space` in `filter` - /// are applied. - pub fn filter_traces( - self, filter: &TraceFilter, - ) -> Result, String> { - let mut traces = Vec::new(); - let mut stack = Vec::new(); - for trace in self.0 { - match &trace.action { - Action::Call(call) => { - if call.space == filter.space - && filter.from_address.matches(&call.from) - && filter.to_address.matches(&call.to) - && filter.action_types.matches(&ActionType::Call) - { - stack.push(true); - traces.push(trace); - } else { - // The corresponding result should be ignored. - stack.push(false); - } - } - Action::Create(create) => { - if create.space == filter.space - && filter.from_address.matches(&create.from) - // TODO(lpl): openethereum uses `to_address` to filter the contract address. - && filter.action_types.matches(&ActionType::Create) - { - stack.push(true); - traces.push(trace); - } else { - // The corresponding result should be ignored. - stack.push(false); - } - } - Action::CallResult(_) | Action::CreateResult(_) => { - if stack - .pop() - .ok_or("result left unmatched!".to_string())? - { - // Since we know that traces should be paired correctly, - // we do not check if the type - // is correct here. - traces.push(trace); - } - } - Action::InternalTransferAction(_) => { - traces.push(trace); - } - } - } - if !stack.is_empty() { - bail!("actions left unmatched!".to_string()); - } - Ok(traces) - } - - pub fn filter_space(self, space: Space) -> Self { - // `unwrap` here should always succeed. - // `vec![]` is just added in case. - Self( - self.filter_traces(&TraceFilter::space_filter(space)) - .unwrap_or(vec![]), - ) - } -} - -impl Into> for TransactionExecTraces { - fn into(self) -> Vec { self.0 } -} - -/// Represents all traces produced by transactions in a single block. -#[derive( - Debug, PartialEq, Clone, Default, RlpEncodable, RlpDecodable, MallocSizeOf, -)] -pub struct BlockExecTraces(pub Vec); - -impl From> for BlockExecTraces { - fn from(v: Vec) -> Self { BlockExecTraces(v) } -} - -impl BlockExecTraces { - /// Returns bloom of all traces in the block. - pub fn bloom(&self) -> Bloom { - self.0.iter().fold(Default::default(), |bloom, tx_traces| { - bloom | tx_traces.bloom() - }) - } - - pub fn filter_space(self, space: Space) -> Self { - Self( - self.0 - .into_iter() - .map(|tx_trace| tx_trace.filter_space(space)) - .collect(), - ) - } -} - -impl Into> for BlockExecTraces { - fn into(self) -> Vec { self.0 } -} - -impl DatabaseDecodable for BlockExecTraces { - fn db_decode(bytes: &[u8]) -> Result { - rlp::decode(bytes) - } -} - -impl DatabaseEncodable for BlockExecTraces { - fn db_encode(&self) -> Bytes { rlp::encode(self) } -} - -pub fn recover_phantom_trace_for_withdraw( - mut tx_traces: impl Iterator, -) -> Result, String> { - let trace = match tx_traces.next() { - Some(t) => t, - None => { - error!("Unable to recover phantom trace: no more traces (expected withdraw)"); - return Err("Unable to recover phantom trace: no more traces (expected withdraw)".into()); - } - }; - - match trace.action { - Action::InternalTransferAction(InternalTransferAction { - from: - AddressPocket::Balance(AddressWithSpace { - address: from, - space: Space::Ethereum, - }), - to: - AddressPocket::Balance(AddressWithSpace { - address: _, - space: Space::Native, - }), - value, - }) => { - return Ok(vec![TransactionExecTraces(vec![ - ExecTrace { - action: Action::Call(Call { - space: Space::Ethereum, - from, - to: Address::zero(), - value, - gas: 0.into(), - input: Default::default(), - call_type: CallType::Call, - }), - valid: true, - }, - ExecTrace { - action: Action::CallResult(CallResult { - outcome: Outcome::Success, - gas_left: 0.into(), - return_data: Default::default(), - }), - valid: true, - }, - ])]); - } - - _ => { - error!("Unable to recover phantom trace: unexpected trace type while processing withdraw: {:?}", trace); - return Err("Unable to recover phantom trace: unexpected trace type while processing withdraw".into()); - } - } -} - -pub fn recover_phantom_trace_for_call( - tx_traces: &mut impl Iterator, original_tx_hash: H256, - cross_space_nonce: u32, -) -> Result, String> -{ - let mut traces = vec![]; - - let trace = match tx_traces.next() { - Some(t) => t, - None => { - error!("Unable to recover phantom trace: no more traces (expected balance transfer) hash={:?}, nonce={:?}", original_tx_hash, cross_space_nonce); - return Err("Unable to recover phantom trace: no more traces (expected balance transfer)".into()); - } - }; - - match trace.action { - Action::InternalTransferAction(InternalTransferAction { - from: _, - to: - AddressPocket::Balance(AddressWithSpace { - address, - space: Space::Ethereum, - }), - value, - }) => { - let input = - (original_tx_hash, U256::from(cross_space_nonce)).abi_encode(); - - traces.push(TransactionExecTraces(vec![ - ExecTrace { - action: Action::Call(Call { - space: Space::Ethereum, - from: Address::zero(), - to: address, - value, - gas: 0.into(), - input, - call_type: CallType::Call, - }), - valid: true, - }, - ExecTrace { - action: Action::CallResult(CallResult { - outcome: Outcome::Success, - gas_left: 0.into(), - return_data: Default::default(), - }), - valid: true, - }, - ])); - } - - _ => { - error!("Unable to recover phantom trace: unexpected trace type while processing call (hash={:?}, nonce={:?}): {:?}", original_tx_hash, cross_space_nonce, trace); - return Err("Unable to recover phantom trace: unexpected trace type while processing call".into()); - } - } - - let mut stack_depth = 0; - let mut phantom_traces = vec![]; - - loop { - let mut trace = match tx_traces.next() { - Some(t) => t, - None => { - error!("Unable to recover phantom trace: no more traces (expected eSpace trace entry) hash={:?}, nonce={:?}", original_tx_hash, cross_space_nonce); - return Err("Unable to recover phantom trace: no more traces (expected eSpace trace entry)".into()); - } - }; - - // phantom traces have 0 gas - match trace.action { - Action::Call(Call { ref mut gas, .. }) => { - *gas = 0.into(); - } - Action::Create(Create { ref mut gas, .. }) => { - *gas = 0.into(); - } - Action::CallResult(CallResult { - ref mut gas_left, .. - }) => { - *gas_left = 0.into(); - } - Action::CreateResult(CreateResult { - ref mut gas_left, .. - }) => { - *gas_left = 0.into(); - } - Action::InternalTransferAction(InternalTransferAction { - .. - }) => {} - } - - phantom_traces.push(trace); - - match phantom_traces.last().as_ref().unwrap().action { - Action::Call(_) | Action::Create(_) => { - stack_depth += 1; - } - Action::CallResult(_) | Action::CreateResult(_) => { - stack_depth -= 1; - - if stack_depth == 0 { - break; - } - } - _ => {} - } - } - - traces.push(TransactionExecTraces(phantom_traces)); - Ok(traces) -} - -pub fn recover_phantom_traces( - tx_traces: TransactionExecTraces, original_tx_hash: H256, -) -> Result, String> { - let mut traces: Vec = vec![]; - let mut traces_iter = tx_traces.0.into_iter(); - let mut cross_space_nonce = 0u32; - - loop { - let trace = match traces_iter.next() { - Some(t) => t, - None => break, - }; - - match trace.action { - Action::Call(Call { - space: Space::Native, - to, - call_type: CallType::Call, - input, - .. - }) if to == CROSS_SPACE_CONTRACT_ADDRESS - && trace.valid - && is_call_create_sig(&input[0..4]) => - { - let phantom_traces = recover_phantom_trace_for_call( - &mut traces_iter, - original_tx_hash, - cross_space_nonce, - )?; - - traces.extend(phantom_traces); - cross_space_nonce += 1; - } - Action::Call(Call { - space: Space::Native, - to, - call_type: CallType::Call, - input, - .. - }) if to == CROSS_SPACE_CONTRACT_ADDRESS - && trace.valid - && is_withdraw_sig(&input[0..4]) => - { - let phantom_traces = - recover_phantom_trace_for_withdraw(&mut traces_iter)?; - - traces.extend(phantom_traces); - } - _ => {} - } - } - - Ok(traces) -} - -#[cfg(test)] -mod tests { - use crate::{ - observer::trace::{ - Action, BlockExecTraces, Call, ExecTrace, TransactionExecTraces, - }, - vm::CallType, - }; - use rlp::*; - - #[test] - fn encode_flat_transaction_traces() { - let ftt = TransactionExecTraces::from(Vec::new()); - - let mut s = RlpStream::new_list(2); - s.append(&ftt); - assert!(!s.is_finished(), "List shouldn't finished yet"); - s.append(&ftt); - assert!(s.is_finished(), "List should be finished now"); - s.out(); - } - - #[test] - fn encode_flat_block_traces() { - let fbt = BlockExecTraces::from(Vec::new()); - - let mut s = RlpStream::new_list(2); - s.append(&fbt); - assert!(!s.is_finished(), "List shouldn't finished yet"); - s.append(&fbt); - assert!(s.is_finished(), "List should be finished now"); - s.out(); - } - - #[test] - fn test_trace_serialization() { - // block #51921 - - let flat_trace = ExecTrace { - action: Action::Call(Call { - space: Default::default(), - from: "8dda5e016e674683241bf671cced51e7239ea2bc" - .parse() - .unwrap(), - to: "37a5e19cc2d49f244805d5c268c0e6f321965ab9".parse().unwrap(), - value: "3627e8f712373c0000".parse().unwrap(), - gas: 0x03e8.into(), - input: vec![], - call_type: CallType::Call, - }), - valid: true, - }; - - let flat_trace1 = ExecTrace { - action: Action::Call(Call { - space: Default::default(), - from: "3d0768da09ce77d25e2d998e6a7b6ed4b9116c2d" - .parse() - .unwrap(), - to: "412fda7643b37d436cb40628f6dbbb80a07267ed".parse().unwrap(), - value: 0.into(), - gas: 0x010c78.into(), - input: vec![0x41, 0xc0, 0xe1, 0xb5], - call_type: CallType::Call, - }), - valid: true, - }; - - let block_traces = BlockExecTraces(vec![ - TransactionExecTraces(vec![flat_trace]), - TransactionExecTraces(vec![flat_trace1]), - ]); - - let encoded = ::rlp::encode(&block_traces); - let decoded = - ::rlp::decode(&encoded).expect("error decoding block traces"); - assert_eq!(block_traces, decoded); - } -} diff --git a/core/src/observer/trace_filter.rs b/core/src/observer/trace_filter.rs deleted file mode 100644 index 01dbc02606..0000000000 --- a/core/src/observer/trace_filter.rs +++ /dev/null @@ -1,80 +0,0 @@ -use crate::observer::trace::ActionType; -use cfx_types::{Address, Space, H256}; -use primitives::EpochNumber; - -/// Log event Filter. -#[derive(Debug, PartialEq)] -pub struct TraceFilter { - /// Search will be applied from this epoch number. - pub from_epoch: EpochNumber, - - /// Till this epoch number. - pub to_epoch: EpochNumber, - - /// Search will be applied in these blocks if given. - /// This will override from/to_epoch fields. - pub block_hashes: Option>, - - /// Search from_address. - /// An empty vector matches all addresses. - pub from_address: ListFilter
, - - /// Search to_address. - /// An empty vector matches all addresses. - pub to_address: ListFilter
, - - /// Search action. - /// - /// If None, match all. - /// If specified, trace must match one of these action types. - pub action_types: ListFilter, - - /// The offset trace number. - pub after: Option, - - /// The number of traces to display in a batch. - pub count: Option, - - /// The space to filter. This field is set according to RPC endpoints and - /// cannot be set by RPC parameters. - pub space: Space, -} - -impl TraceFilter { - pub fn space_filter(space: Space) -> TraceFilter { - TraceFilter { - from_epoch: EpochNumber::Earliest, - to_epoch: EpochNumber::LatestState, - block_hashes: None, - from_address: Default::default(), - to_address: Default::default(), - action_types: Default::default(), - after: None, - count: None, - space, - } - } -} - -#[derive(Debug, PartialEq)] -pub struct ListFilter { - list: Vec, -} - -impl Default for ListFilter { - fn default() -> Self { ListFilter { list: Vec::new() } } -} - -impl From> for ListFilter { - fn from(addresses: Vec) -> Self { ListFilter { list: addresses } } -} - -impl ListFilter { - /// Returns true if address matches one of the searched addresses. - pub fn matches(&self, address: &T) -> bool { - self.matches_all() || self.list.contains(address) - } - - /// Returns true if this address filter matches everything. - pub fn matches_all(&self) -> bool { self.list.is_empty() } -} diff --git a/core/src/pos/consensus/executor/src/vm.rs b/core/src/pos/consensus/executor/src/vm.rs deleted file mode 100644 index e8823514ad..0000000000 --- a/core/src/pos/consensus/executor/src/vm.rs +++ /dev/null @@ -1,365 +0,0 @@ -use std::collections::BTreeMap; - -use consensus_types::{block::Block, vote::Vote}; -use diem_logger::{error as diem_error, prelude::*}; -use diem_state_view::StateView; -use diem_types::{ - account_address::from_consensus_public_key, - contract_event::ContractEvent, - epoch_state::EpochState, - on_chain_config::{self, new_epoch_event_key, OnChainConfig, ValidatorSet}, - term_state::pos_state_config::{PosStateConfigTrait, POS_STATE_CONFIG}, - transaction::{ - authenticator::TransactionAuthenticator, ConflictSignature, - DisputePayload, Transaction, TransactionOutput, TransactionPayload, - TransactionStatus, WriteSetPayload, - }, - validator_verifier::{ValidatorConsensusInfo, ValidatorVerifier}, - vm_status::{KeptVMStatus, StatusCode, VMStatus}, - write_set::{WriteOp, WriteSetMut}, -}; - -/// This trait describes the VM's execution interface. -pub trait VMExecutor: Send { - // NOTE: At the moment there are no persistent caches that live past the end - // of a block (that's why execute_block doesn't take &self.) - // There are some cache invalidation issues around transactions publishing - // code that need to be sorted out before that's possible. - - /// Executes a block of transactions and returns output for each one of - /// them. - fn execute_block( - transactions: Vec, state_view: &dyn StateView, - catch_up_mode: bool, - ) -> Result, VMStatus>; -} - -/// A fake VM implementing VMExecutor -pub struct FakeVM; - -impl VMExecutor for FakeVM { - fn execute_block( - transactions: Vec, state_view: &dyn StateView, - catch_up_mode: bool, - ) -> Result, VMStatus> - { - let mut vm_outputs = Vec::new(); - for transaction in transactions { - // Execute the transaction - match transaction { - Transaction::BlockMetadata(_) => { - let mut events = state_view.pos_state().get_unlock_events(); - diem_debug!("get_unlock_events: {}", events.len()); - // TODO(lpl): Simplify. - if (state_view.pos_state().current_view() + 1) - % POS_STATE_CONFIG.round_per_term() - == 0 - { - let term = (state_view.pos_state().current_view() + 1) - / POS_STATE_CONFIG.round_per_term(); - let (validator_verifier, vrf_seed) = state_view - .pos_state() - .get_committee_at(term) - .map_err(|e| { - diem_warn!("get_new_committee error: {:?}", e); - VMStatus::Error(StatusCode::CFX_INVALID_TX) - })?; - let epoch = (state_view.pos_state().current_view() + 1) - / POS_STATE_CONFIG.round_per_term() - + 1; - let validator_bytes = bcs::to_bytes(&EpochState::new( - epoch, - validator_verifier, - vrf_seed, - )) - .unwrap(); - let contract_event = ContractEvent::new( - new_epoch_event_key(), - validator_bytes, - ); - events.push(contract_event); - } - let output = Self::gen_output(events, false); - vm_outputs.push(output); - } - Transaction::UserTransaction(trans) => { - // TODO(lpl): Parallel verification. - let trans = trans.check_signature().map_err(|e| { - diem_trace!( - "invalid transactions signature: e={:?}", - e - ); - VMStatus::Error(StatusCode::INVALID_SIGNATURE) - })?; - /* TODO(lpl): Handle pos epoch change. - if verify_admin_transaction && trans.is_admin_type() { - info!("executing admin trans"); - // Check the voting power of signers in administrators. - let admins = self.validators.read(); - if admins.is_none() { - bail!("Administrators are not set."); - } - let admins = admins.as_ref().unwrap(); - let signers = trans.pubkey_account_addresses(); - match admins.check_voting_power(signers.iter()) { - Ok(_) => {} - Err(VerifyError::TooLittleVotingPower { - .. - }) => { - bail!("Not enough voting power in administrators."); - } - Err(_) => { - bail!( - "There are signers not in administrators." - ); - } - } - } - */ - let payload = trans.payload(); - let events = match payload { - TransactionPayload::WriteSet( - WriteSetPayload::Direct(change_set), - ) => change_set.events().to_vec(), - TransactionPayload::Election(election_payload) => { - if !catch_up_mode { - state_view - .pos_state() - .validate_election(election_payload) - .map_err(|e| { - diem_error!( - "election tx error: {:?}", - e - ); - VMStatus::Error( - StatusCode::CFX_INVALID_TX, - ) - })?; - } - vec![election_payload.to_event()] - } - TransactionPayload::Retire(retire_payload) => { - vec![retire_payload.to_event()] - } - TransactionPayload::PivotDecision(pivot_decision) => { - if !catch_up_mode { - let authenticator = trans.authenticator(); - let signature = match authenticator { - TransactionAuthenticator::MultiBLS { - signature, - } => Ok(signature), - _ => Err(VMStatus::Error( - StatusCode::CFX_INVALID_TX, - )), - }?; - state_view - .pos_state() - .validate_pivot_decision( - pivot_decision, - signature, - ) - .map_err(|e| { - diem_error!( - "pivot decision tx error: {:?}", - e - ); - VMStatus::Error( - StatusCode::CFX_INVALID_TX, - ) - })?; - } - vec![pivot_decision.to_event()] - } - TransactionPayload::Register(register) => { - vec![register.to_event()] - } - TransactionPayload::UpdateVotingPower(update) => { - vec![update.to_event()] - } - TransactionPayload::Dispute(dispute) => { - state_view - .pos_state() - .validate_dispute(dispute) - .map_err(|e| { - diem_error!("dispute tx error: {:?}", e); - VMStatus::Error(StatusCode::CFX_INVALID_TX) - })?; - if !Self::verify_dispute(dispute) { - return Err(VMStatus::Error( - StatusCode::CFX_INVALID_TX, - )); - } - vec![dispute.to_event()] - } - _ => { - return Err(VMStatus::Error( - StatusCode::CFX_UNEXPECTED_TX, - )) - } - }; - - // ensure!( - // events.len() == 1, - // "One transaction can contain exactly 1 event." - // ); - - let output = Self::gen_output(events, false); - vm_outputs.push(output); - } - Transaction::GenesisTransaction(change_set) => { - let events = match change_set { - WriteSetPayload::Direct(change_set) => { - change_set.events().to_vec() - } - _ => { - return Err(VMStatus::Error( - StatusCode::CFX_UNEXPECTED_TX, - )) - } - }; - // ensure!( - // events.len() == 1, - // "One transaction can contain exactly 1 event." - // ); - - let output = Self::gen_output(events, true); - vm_outputs.push(output); - } - } - } - - Ok(vm_outputs) - } -} - -impl FakeVM { - fn gen_output( - events: Vec, write: bool, - ) -> TransactionOutput { - let new_epoch_event_key = on_chain_config::new_epoch_event_key(); - let status = TransactionStatus::Keep(KeptVMStatus::Executed); - let mut write_set = WriteSetMut::default(); - - // TODO(linxi): support other event key - if write { - for event in &events { - if *event.key() == new_epoch_event_key { - write_set.push(( - ValidatorSet::CONFIG_ID.access_path(), - WriteOp::Value(event.event_data().to_vec()), - )); - } - } - } - - TransactionOutput::new(write_set.freeze().unwrap(), events, 0, status) - } - - /// Return true if the dispute is valid. - /// Return false if the encoding is invalid or the provided signatures are - /// not from the same round. - pub fn verify_dispute(dispute: &DisputePayload) -> bool { - let computed_address = from_consensus_public_key( - &dispute.bls_pub_key, - &dispute.vrf_pub_key, - ); - if dispute.address != computed_address { - diem_trace!("Incorrect address and public keys"); - return false; - } - match &dispute.conflicting_votes { - ConflictSignature::Proposal((proposal_byte1, proposal_byte2)) => { - let proposal1: Block = - match bcs::from_bytes(proposal_byte1.as_slice()) { - Ok(proposal) => proposal, - Err(e) => { - diem_trace!("1st proposal encoding error: {:?}", e); - return false; - } - }; - let proposal2: Block = - match bcs::from_bytes(proposal_byte2.as_slice()) { - Ok(proposal) => proposal, - Err(e) => { - diem_trace!("2nd proposal encoding error: {:?}", e); - return false; - } - }; - if proposal1 == proposal2 { - diem_trace!( - "Two same proposals are claimed to be conflict" - ); - return false; - } - if (proposal1.block_data().epoch() - != proposal2.block_data().epoch()) - || (proposal1.block_data().round() - != proposal2.block_data().round()) - { - diem_trace!("Two proposals are from different rounds"); - return false; - } - let mut temp_map = BTreeMap::new(); - temp_map.insert( - dispute.address, - ValidatorConsensusInfo::new( - dispute.bls_pub_key.clone(), - Some(dispute.vrf_pub_key.clone()), - 1, - ), - ); - let temp_verifier = ValidatorVerifier::new(temp_map); - if proposal1.validate_signature(&temp_verifier).is_err() - || proposal2.validate_signature(&temp_verifier).is_err() - { - return false; - } - } - ConflictSignature::Vote((vote_byte1, vote_byte2)) => { - let vote1: Vote = match bcs::from_bytes(vote_byte1.as_slice()) { - Ok(vote) => vote, - Err(e) => { - diem_trace!("1st vote encoding error: {:?}", e); - return false; - } - }; - let vote2: Vote = match bcs::from_bytes(vote_byte2.as_slice()) { - Ok(vote) => vote, - Err(e) => { - diem_trace!("2nd vote encoding error: {:?}", e); - return false; - } - }; - if vote1 == vote2 { - diem_trace!("Two same votes are claimed to be conflict"); - return false; - } - if (vote1.vote_data().proposed().epoch() - != vote2.vote_data().proposed().epoch()) - || (vote1.vote_data().proposed().round() - != vote2.vote_data().proposed().round()) - { - diem_trace!("Two votes are from different rounds"); - return false; - } - let mut temp_map = BTreeMap::new(); - temp_map.insert( - dispute.address, - ValidatorConsensusInfo::new( - dispute.bls_pub_key.clone(), - Some(dispute.vrf_pub_key.clone()), - 1, - ), - ); - let temp_verifier = ValidatorVerifier::new(temp_map); - if vote1.verify(&temp_verifier).is_err() - || vote2.verify(&temp_verifier).is_err() - { - diem_trace!("dispute vote verification error: vote1_r={:?} vote2_r={:?}", vote1.verify(&temp_verifier), vote2.verify(&temp_verifier)); - return false; - } - } - } - true - } -} diff --git a/core/src/spec/mod.rs b/core/src/spec/mod.rs deleted file mode 100644 index 25e7055247..0000000000 --- a/core/src/spec/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2019 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -pub mod genesis; -mod spec; -pub use self::spec::{CommonParams, TransitionsEpochHeight}; diff --git a/core/src/state/account_entry.rs b/core/src/state/account_entry.rs deleted file mode 100644 index d0e8f84e09..0000000000 --- a/core/src/state/account_entry.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2019 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -use super::overlay_account::OverlayAccount; -use cfx_types::U256; - -#[derive(Debug)] -/// In-memory copy of the account data. Holds the optional account -/// and the modification status. -/// Account entry can contain existing (`Some`) or non-existing -/// account (`None`) -pub struct AccountEntry { - /// Account proxy. `None` if account known to be non-existent. - pub account: Option, - /// Unmodified account balance. - pub old_balance: Option, - // FIXME: remove it. - /// Entry state. - pub state: AccountState, -} - -impl AccountEntry { - // FIXME: remove it. - pub fn is_dirty(&self) -> bool { self.state == AccountState::Dirty } - - pub fn overwrite_with(&mut self, other: AccountEntry) { - self.state = other.state; - match other.account { - Some(acc) => { - if let Some(ref mut ours) = self.account { - ours.overwrite_with(acc); - } else { - self.account = Some(acc); - } - } - None => self.account = None, - } - } - - /// Clone dirty data into new `AccountEntry`. This includes - /// basic account data and modified storage keys. - pub fn clone_dirty(&self) -> AccountEntry { - AccountEntry { - old_balance: self.old_balance, - account: self.account.as_ref().map(OverlayAccount::clone_dirty), - state: self.state, - } - } - - pub fn new_dirty(account: Option) -> AccountEntry { - AccountEntry { - old_balance: account.as_ref().map(|acc| acc.balance().clone()), - account, - state: AccountState::Dirty, - } - } - - pub fn new_clean(account: Option) -> AccountEntry { - AccountEntry { - old_balance: account.as_ref().map(|acc| acc.balance().clone()), - account, - state: AccountState::CleanFresh, - } - } -} - -#[derive(Eq, PartialEq, Clone, Copy, Debug)] -/// Account modification state. Used to check if the account was -/// Modified in between commits and overall. -#[allow(dead_code)] -pub enum AccountState { - /// Account was loaded from disk and never modified in this state object. - CleanFresh, - /// Account was loaded from the global cache and never modified. - CleanCached, - /// Account has been modified and is not committed to the trie yet. - /// This is set if any of the account data is changed, including - /// storage and code. - Dirty, - /// Account was modified and committed to the trie. - Committed, -} diff --git a/core/src/state/mod.rs b/core/src/state/mod.rs deleted file mode 100644 index cf126006d4..0000000000 --- a/core/src/state/mod.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2019 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -mod account_entry; -mod overlay_account; - -mod global_stat; -pub mod prefetcher; -mod state_object; -mod substate; -mod trace; - -use cfx_bytes::Bytes; -use cfx_state::CleanupMode; -use cfx_types::Address; -use primitives::{DepositList, VoteStakeList}; -use std::sync::Arc; - -pub use overlay_account::COMMISSION_PRIVILEGE_SPECIAL_KEY; -pub use state_object::{ - distribute_pos_interest, initialize_or_update_dao_voted_params, - settle_collateral_for_all, update_pos_status, State, -}; -pub use substate::{cleanup_mode, CallStackInfo, Substate}; - -/// Methods that are intentionally kept private because the fields may not have -/// been loaded from db. -trait AccountEntryProtectedMethods { - fn deposit_list(&self) -> Option<&DepositList>; - fn vote_stake_list(&self) -> Option<&VoteStakeList>; - fn code_size(&self) -> Option; - fn code(&self) -> Option>; - fn code_owner(&self) -> Option
; -} diff --git a/core/src/state/overlay_account/mod.rs b/core/src/state/overlay_account/mod.rs deleted file mode 100644 index 4e4989d51d..0000000000 --- a/core/src/state/overlay_account/mod.rs +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright 2019 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -#[cfg(test)] -mod tests; - -mod basic; -mod collateral; -mod commit; -mod factory; -mod sponsor; -mod staking; -mod storage; - -use super::{ - account_entry::AccountEntry, substate::Substate, - AccountEntryProtectedMethods, -}; - -use crate::{bytes::Bytes, hash::KECCAK_EMPTY}; - -use cfx_statedb::{Result as DbResult, StateDbExt, StateDbGeneric}; -#[cfg(test)] -use cfx_types::AddressSpaceUtil; -use cfx_types::{ - address_util::AddressUtil, Address, AddressWithSpace, Space, H256, U256, -}; -use parking_lot::RwLock; -use primitives::{ - is_default::IsDefault, CodeInfo, DepositList, SponsorInfo, StorageLayout, - VoteStakeList, -}; -use std::{collections::HashMap, sync::Arc}; - -pub use sponsor::COMMISSION_PRIVILEGE_SPECIAL_KEY; - -#[derive(Debug)] -/// Single account in the system. -/// Keeps track of changes to the code and storage. -/// The changes are applied in `commit_storage` and `commit_code` -pub struct OverlayAccount { - address: AddressWithSpace, - - // Balance of the account. - balance: U256, - // Nonce of the account, - nonce: U256, - - // Administrator of the account - admin: Address, - - // This is the sponsor information of the contract. - sponsor_info: SponsorInfo, - - // FIXME: there are changes, so no need to have cache for both storage and - // ownership - - // This is a read cache for storage values of the current account in db. - // The underlying db will not change while computing transactions in an - // epoch. So all the contents in the read cache is always available. - storage_value_read_cache: Arc, U256>>>, - // This is a write cache for changing storage value in db. It will be - // written to db when committing overlay account. - storage_value_write_cache: Arc, U256>>, - - // This is a level 2 cache for storage ownership change of the current - // account. It will be written to db when committing overlay account. - // - // This cache contains intermediate result during transaction execution, it - // should never be shared among multiple threads. But we also need RwLock - // here because current implementation requires OverlayAccount: Send + - // Sync. - storage_owner_lv2_write_cache: - RwLock, Option
>>>, - // This is a level 1 cache for storage ownership change of the current - // account. It will be updated when executing EVM or calling - // `set_storage` function. It will be merged to level 2 cache at the - // end of message call or calling `collect_commit_changes`. - // - // This maintains the current owner of a - // specific key. If the owner is `None`, the value of current key is - // zero. - storage_owner_lv1_write_cache: Arc, Option
>>, - - // Storage layout change. - storage_layout_change: Option, - - // This is the number of tokens used in staking. - staking_balance: U256, - // This is the number of tokens used as collateral for storage, which will - // be returned to balance if the storage is released. - collateral_for_storage: U256, - // This is the accumulated interest return. - accumulated_interest_return: U256, - // This is the list of deposit info, sorted in increasing order of - // `deposit_time`. - // If it is not `None`, which means it has been loaded from db. - deposit_list: Option, - // This is the list of vote info. The `unlock_block_number` sorted in - // increasing order and the `amount` is sorted in decreasing order. All - // the `unlock_block_number` and `amount` is unique in the list. - // If it is not `None`, which means it has been loaded from db. - vote_stake_list: Option, - - // Code hash of the account. - code_hash: H256, - // When code_hash isn't KECCAK_EMPTY, the code has been initialized for - // the account. The code field can be None, which means that the code - // has not been loaded from storage. When code_hash is KECCAK_EMPTY, this - // field always None. - code: Option, - - // This flag indicates whether it is a newly created contract. For such - // account, we will skip looking data from the disk. This flag will stay - // true until the contract being committed and cleared from the memory. - // - // If the contract account at the same address is killed, then the same - // account is re-created, this flag is also true, to indicate that any - // pending cleanups must be done. The re-creation of the account can - // also be caused by a simple payment transaction, which result into a new - // basic account at the same address. - is_newly_created_contract: bool, - invalidated_storage: bool, -} - -impl OverlayAccount { - pub fn is_contract(&self) -> bool { - self.code_hash != KECCAK_EMPTY || self.is_newly_created_contract - } - - pub fn removed_without_update(&self) -> bool { - self.invalidated_storage && self.as_account().is_default() - } - - #[cfg(test)] - pub fn is_newly_created_contract(&self) -> bool { - self.is_newly_created_contract - } - - #[cfg(test)] - pub fn is_basic(&self) -> bool { self.code_hash == KECCAK_EMPTY } - - pub fn cache_code(&mut self, db: &StateDbGeneric) -> DbResult { - trace!( - "OverlayAccount::cache_code: ic={}; self.code_hash={:?}, self.code_cache={:?}", - self.is_code_loaded(), self.code_hash, self.code); - - if self.is_code_loaded() { - return Ok(true); - } - - self.code = db.get_code(&self.address, &self.code_hash)?; - match &self.code { - Some(_) => Ok(true), - _ => { - warn!( - "Failed to get code {:?} for address {:?}", - self.code_hash, self.address - ); - Ok(false) - } - } - } - - fn fresh_storage(&self) -> bool { - let builtin_address = self.address.space == Space::Native - && self.address.address.is_builtin_address(); - (self.is_newly_created_contract && !builtin_address) - || self.invalidated_storage - } - - pub fn invalidated_storage(&self) -> bool { self.invalidated_storage } - - pub fn cache_ext_fields( - &mut self, cache_deposit_list: bool, cache_vote_list: bool, - db: &StateDbGeneric, - ) -> DbResult - { - self.address.assert_native(); - if cache_deposit_list && self.deposit_list.is_none() { - let deposit_list_opt = if self.fresh_storage() { - None - } else { - db.get_deposit_list(&self.address)? - }; - self.deposit_list = Some(deposit_list_opt.unwrap_or_default()); - } - if cache_vote_list && self.vote_stake_list.is_none() { - let vote_list_opt = if self.fresh_storage() { - None - } else { - db.get_vote_list(&self.address)? - }; - self.vote_stake_list = Some(vote_list_opt.unwrap_or_default()); - } - Ok(true) - } -} - -impl AccountEntryProtectedMethods for OverlayAccount { - /// This method is intentionally kept private because the field may not have - /// been loaded from db. - fn deposit_list(&self) -> Option<&DepositList> { - self.deposit_list.as_ref() - } - - /// This method is intentionally kept private because the field may not have - /// been loaded from db. - fn vote_stake_list(&self) -> Option<&VoteStakeList> { - self.vote_stake_list.as_ref() - } - - /// This method is intentionally kept private because the field may not have - /// been loaded from db. - fn code_size(&self) -> Option { - self.code.as_ref().map(|c| c.code_size()) - } - - /// This method is intentionally kept private because the field may not have - /// been loaded from db. - fn code(&self) -> Option> { - self.code.as_ref().map(|c| c.code.clone()) - } - - /// This method is intentionally kept private because the field may not have - /// been loaded from db. - fn code_owner(&self) -> Option
{ - self.code.as_ref().map(|c| c.owner) - } -} - -#[cfg(test)] -mod tests_another { - use super::*; - use crate::test_helpers::get_state_for_genesis_write; - use cfx_storage::tests::new_state_manager_for_unit_test; - use primitives::is_default::IsDefault; - use std::str::FromStr; - - fn test_account_is_default(account: &mut OverlayAccount) { - let storage_manager = new_state_manager_for_unit_test(); - let state = get_state_for_genesis_write(&storage_manager); - - assert!(account.as_account().is_default()); - - account.cache_ext_fields(true, true, &state.db).unwrap(); - assert!(account.vote_stake_list().unwrap().is_default()); - assert!(account.deposit_list().unwrap().is_default()); - } - - #[test] - fn new_overlay_account_is_default() { - let normal_addr = - Address::from_str("1000000000000000000000000000000000000000") - .unwrap() - .with_native_space(); - let builtin_addr = - Address::from_str("0000000000000000000000000000000000000000") - .unwrap() - .with_native_space(); - - test_account_is_default(&mut OverlayAccount::new_basic( - &normal_addr, - U256::zero(), - )); - test_account_is_default(&mut OverlayAccount::new_basic( - &builtin_addr, - U256::zero(), - )); - } -} diff --git a/core/src/state/overlay_account/storage.rs b/core/src/state/overlay_account/storage.rs deleted file mode 100644 index e20d85446f..0000000000 --- a/core/src/state/overlay_account/storage.rs +++ /dev/null @@ -1,238 +0,0 @@ -use super::Substate; - -#[cfg(test)] -use super::StorageLayout; -use cfx_parameters::{ - internal_contract_addresses::SYSTEM_STORAGE_ADDRESS, - staking::COLLATERAL_UNITS_PER_STORAGE_KEY, -}; -use cfx_statedb::{Result as DbResult, StateDbExt, StateDbGeneric}; -use cfx_types::{Address, AddressWithSpace, Space, U256}; - -use primitives::{StorageKey, StorageValue}; -use std::{collections::HashMap, sync::Arc}; - -use super::OverlayAccount; - -impl OverlayAccount { - pub fn set_storage(&mut self, key: Vec, value: U256, owner: Address) { - Arc::make_mut(&mut self.storage_value_write_cache) - .insert(key.clone(), value); - if self.address.space == Space::Ethereum - || self.address.address == SYSTEM_STORAGE_ADDRESS - { - return; - } - let lv1_write_cache = - Arc::make_mut(&mut self.storage_owner_lv1_write_cache); - if value.is_zero() { - lv1_write_cache.insert(key, None); - } else { - lv1_write_cache.insert(key, Some(owner)); - } - } - - pub fn cached_storage_at(&self, key: &[u8]) -> Option { - if let Some(value) = self.storage_value_write_cache.get(key) { - return Some(value.clone()); - } - if let Some(value) = self.storage_value_read_cache.read().get(key) { - return Some(value.clone()); - } - None - } - - // If a contract is removed, and then some one transfer balance to it, - // `storage_at` will return incorrect value. But this case should never - // happens. - pub fn storage_at( - &self, db: &StateDbGeneric, key: &[u8], - ) -> DbResult { - if let Some(value) = self.cached_storage_at(key) { - return Ok(value); - } - if self.fresh_storage() { - Ok(U256::zero()) - } else { - Self::get_and_cache_storage( - &mut self.storage_value_read_cache.write(), - Arc::make_mut(&mut *self.storage_owner_lv2_write_cache.write()), - db, - &self.address, - key, - true, /* cache_ownership */ - ) - } - } - - pub fn storage_opt_at( - &self, db: &StateDbGeneric, key: &[u8], - ) -> DbResult> { - if let Some(value) = self.cached_storage_at(key) { - return Ok(Some(value)); - } - if self.fresh_storage() { - Ok(None) - } else { - Ok(db - .get::( - StorageKey::new_storage_key( - &self.address.address, - key.as_ref(), - ) - .with_space(self.address.space), - )? - .map(|v| v.value)) - } - } - - fn get_and_cache_storage( - storage_value_read_cache: &mut HashMap, U256>, - storage_owner_lv2_write_cache: &mut HashMap, Option
>, - db: &StateDbGeneric, address: &AddressWithSpace, key: &[u8], - cache_ownership: bool, - ) -> DbResult - { - assert!(!storage_owner_lv2_write_cache.contains_key(key)); - let cache_ownership = cache_ownership - && address.space == Space::Native - && address.address != SYSTEM_STORAGE_ADDRESS; - - if let Some(value) = db.get::( - StorageKey::new_storage_key(&address.address, key.as_ref()) - .with_space(address.space), - )? { - storage_value_read_cache.insert(key.to_vec(), value.value); - if cache_ownership { - storage_owner_lv2_write_cache.insert( - key.to_vec(), - Some(match value.owner { - Some(owner) => owner, - None => address.address, - }), - ); - } - Ok(value.value) - } else { - storage_value_read_cache.insert(key.to_vec(), U256::zero()); - if cache_ownership { - storage_owner_lv2_write_cache.insert(key.to_vec(), None); - } - Ok(U256::zero()) - } - } - - /// Return the owner of `key` before this execution. If it is `None`, it - /// means the value of the key is zero before this execution. Otherwise, the - /// value of the key is nonzero. - pub fn original_ownership_at( - &self, db: &StateDbGeneric, key: &Vec, - ) -> DbResult> { - self.address.assert_native(); - if let Some(value) = self.storage_owner_lv2_write_cache.read().get(key) - { - return Ok(value.clone()); - } - if self.fresh_storage() { - return Ok(None); - } - let storage_value_read_cache = - &mut self.storage_value_read_cache.write(); - let storage_owner_lv2_write_cache = - &mut *self.storage_owner_lv2_write_cache.write(); - let storage_owner_lv2_write_cache = - Arc::make_mut(storage_owner_lv2_write_cache); - Self::get_and_cache_storage( - storage_value_read_cache, - storage_owner_lv2_write_cache, - db, - &self.address, - key, - true, /* cache_ownership */ - )?; - Ok(storage_owner_lv2_write_cache - .get(key) - .expect("key exists") - .clone()) - } - - /// Return the storage change of each related account. - /// Each account is associated with a pair of `(usize, usize)`. The first - /// value means the number of keys occupied by this account in current - /// execution. The second value means the number of keys released by this - /// account in current execution. - pub fn commit_ownership_change( - &mut self, db: &StateDbGeneric, substate: &mut Substate, - ) -> DbResult<()> { - self.address.assert_native(); - if self.invalidated_storage { - return Ok(()); - } - if self.address.address == SYSTEM_STORAGE_ADDRESS { - return Ok(()); - } - let storage_owner_lv1_write_cache: Vec<_> = - Arc::make_mut(&mut self.storage_owner_lv1_write_cache) - .drain() - .collect(); - for (k, current_owner_opt) in storage_owner_lv1_write_cache { - // Get the owner of `k` before execution. If it is `None`, it means - // the value of the key is zero before execution. Otherwise, the - // value of the key is nonzero. - let original_ownership_opt = self.original_ownership_at(db, &k)?; - if original_ownership_opt != current_owner_opt { - if let Some(original_owner) = original_ownership_opt.as_ref() { - // The key has released from previous owner. - substate.record_storage_release( - original_owner, - COLLATERAL_UNITS_PER_STORAGE_KEY, - ); - } - if let Some(current_owner) = current_owner_opt.as_ref() { - // The owner has occupied a new key. - substate.record_storage_occupy( - current_owner, - COLLATERAL_UNITS_PER_STORAGE_KEY, - ); - } - } - // Commit ownership change to `storage_owner_lv2_write_cache`. - Arc::make_mut(self.storage_owner_lv2_write_cache.get_mut()) - .insert(k, current_owner_opt); - } - assert!(self.storage_owner_lv1_write_cache.is_empty()); - Ok(()) - } - - pub fn change_storage_value( - &mut self, db: &StateDbGeneric, key: &[u8], value: U256, - ) -> DbResult<()> { - let current_value = self.storage_at(db, key)?; - if !current_value.is_zero() { - // Constraint requirement: if a key appears in value_write_cache, it - // must be in owner_lv2_write cache. Safety: since - // current value is non-zero, this key must appears in - // lv2_write_cache because `storage_at` loaded it. - Arc::make_mut(&mut self.storage_value_write_cache) - .insert(key.to_vec(), value); - } else { - warn!("Change storage value outside transaction fails: current value is zero, tx {:?}, key {:?}", self.address, key); - } - Ok(()) - } - - #[cfg(test)] - pub fn storage_layout_change(&self) -> Option<&StorageLayout> { - self.storage_layout_change.as_ref() - } - - #[cfg(test)] - pub fn set_storage_layout(&mut self, layout: StorageLayout) { - self.storage_layout_change = Some(layout); - } - - // TODO: consider remove this function - pub fn storage_value_write_cache(&self) -> &HashMap, U256> { - &self.storage_value_write_cache - } -} diff --git a/core/src/state/state_object/account_controller.rs b/core/src/state/state_object/account_controller.rs deleted file mode 100644 index 163631073d..0000000000 --- a/core/src/state/state_object/account_controller.rs +++ /dev/null @@ -1,115 +0,0 @@ -use super::{AccountEntry, OverlayAccount, State}; -use cfx_statedb::Result as DbResult; -use cfx_storage::utils::access_mode; -use cfx_types::{ - Address, AddressSpaceUtil, AddressWithSpace, Space, H256, U256, -}; -#[cfg(test)] -use primitives::storage::STORAGE_LAYOUT_REGULAR_V0; -use primitives::{Account, StorageLayout}; - -impl State { - pub fn new_contract_with_admin( - &mut self, contract: &AddressWithSpace, admin: &Address, balance: U256, - storage_layout: Option, cip107: bool, - ) -> DbResult<()> - { - assert!(contract.space == Space::Native || admin.is_zero()); - // Check if the new contract is deployed on a killed contract in the - // same block. - let invalidated_storage = self - .read_account_lock(contract)? - .map_or(false, |overlay| overlay.invalidated_storage()); - let account_entry = OverlayAccount::new_contract_with_admin( - contract, - balance, - admin, - invalidated_storage, - storage_layout, - cip107, - ) - .into_dirty_entry(); - self.update_cache(contract, account_entry); - Ok(()) - } - - pub fn remove_contract( - &mut self, address: &AddressWithSpace, - ) -> DbResult<()> { - if address.space == Space::Native { - let removed_whitelist = self - .clear_contract_whitelist::( - &address.address, - )?; - - if !removed_whitelist.is_empty() { - error!( - "removed_whitelist here should be empty unless in unit tests." - ); - } - } - - self.update_cache( - address, - OverlayAccount::new_removed(address).into_dirty_entry(), - ); - - Ok(()) - } - - /// A special implementation to fix the bug in function - /// `clean_account` while not changing the genesis result. - pub fn genesis_special_clean_account( - &mut self, address: &Address, - ) -> DbResult<()> { - let address = address.with_native_space(); - let mut account = Account::new_empty(&address); - account.code_hash = H256::default(); - *&mut *self.write_account_or_new_lock(&address)? = - OverlayAccount::from_loaded(&address, account); - Ok(()) - } - - fn update_cache( - &mut self, address: &AddressWithSpace, account: AccountEntry, - ) { - let is_dirty = account.is_dirty(); - let old_value = self.cache.get_mut().insert(*address, account); - if is_dirty { - if let Some(ref mut checkpoint) = - self.checkpoints.get_mut().last_mut() - { - checkpoint.entry(*address).or_insert(old_value); - } - } - } -} - -impl State { - #[cfg(test)] - pub fn new_contract_with_code( - &mut self, contract: &AddressWithSpace, balance: U256, - ) -> DbResult<()> { - self.new_contract(contract, balance)?; - self.init_code(&contract, vec![0x12, 0x34], Address::zero())?; - Ok(()) - } - - #[cfg(test)] - pub fn new_contract( - &mut self, contract: &AddressWithSpace, balance: U256, - ) -> DbResult<()> { - let invalidated_storage = self - .read_account_lock(contract)? - .map_or(false, |acc| acc.invalidated_storage()); - let account_entry = OverlayAccount::new_contract( - &contract.address, - balance, - invalidated_storage, - Some(STORAGE_LAYOUT_REGULAR_V0), - ) - .into_dirty_entry(); - self.update_cache(contract, account_entry); - Ok(()) - } -} diff --git a/core/src/state/state_object/cache_layer.rs b/core/src/state/state_object/cache_layer.rs deleted file mode 100644 index 7c284a3b8c..0000000000 --- a/core/src/state/state_object/cache_layer.rs +++ /dev/null @@ -1,286 +0,0 @@ -use super::{ - AccountEntry, AccountEntryProtectedMethods, AccountState, OverlayAccount, - State, -}; -use cfx_statedb::{ - ErrorKind as DbErrorKind, Result as DbResult, StateDb, StateDbExt, -}; -use cfx_types::{Address, AddressSpaceUtil, AddressWithSpace, U256}; -use parking_lot::{ - MappedRwLockReadGuard, MappedRwLockWriteGuard, RwLockReadGuard, - RwLockUpgradableReadGuard, RwLockWriteGuard, -}; -use std::collections::HashMap; - -pub type AccountReadGuard<'a> = MappedRwLockReadGuard<'a, OverlayAccount>; -pub type AccountWriteGuard<'a> = MappedRwLockWriteGuard<'a, OverlayAccount>; - -#[derive(Copy, Clone)] -pub enum RequireCache { - None, - Code, - DepositList, - VoteStakeList, -} - -impl State { - pub(super) fn read_account_lock( - &self, address: &AddressWithSpace, - ) -> DbResult> { - self.read_account_ext_lock(address, RequireCache::None) - } - - pub(super) fn read_native_account_lock( - &self, address: &Address, - ) -> DbResult> { - self.read_account_lock(&address.with_native_space()) - } - - pub(super) fn read_account_ext_lock( - &self, address: &AddressWithSpace, require: RequireCache, - ) -> DbResult> { - let as_account_guard = |guard| { - MappedRwLockReadGuard::map(guard, |entry: &AccountEntry| { - entry.account.as_ref().unwrap() - }) - }; - - // Return immediately when there is no need to have db operation. - if let Ok(guard) = - RwLockReadGuard::try_map(self.cache.read(), |cache| { - cache.get(address) - }) - { - if let Some(account) = &guard.account { - let needs_update = Self::should_update_cache(require, account); - if !needs_update { - return Ok(Some(as_account_guard(guard))); - } - } else { - return Ok(None); - } - } - - let mut cache_write_lock = { - let upgradable_lock = self.cache.upgradable_read(); - if upgradable_lock.contains_key(address) { - // TODO: the account can be updated here if the relevant methods - // to update account can run with &OverlayAccount. - RwLockUpgradableReadGuard::upgrade(upgradable_lock) - } else { - // Load the account from db. - let mut maybe_loaded_acc = self - .db - .get_account(address)? - .map(|acc| OverlayAccount::from_loaded(address, acc)); - if let Some(account) = &mut maybe_loaded_acc { - Self::should_update_account_cache( - require, account, &self.db, - )?; - } - let mut cache_write_lock = - RwLockUpgradableReadGuard::upgrade(upgradable_lock); - Self::insert_cache_if_fresh_account( - &mut *cache_write_lock, - address, - maybe_loaded_acc, - ); - - cache_write_lock - } - }; - - let cache = &mut *cache_write_lock; - let account = cache.get_mut(address).unwrap(); - if let Some(maybe_acc) = &mut account.account { - if !Self::should_update_account_cache(require, maybe_acc, &self.db)? - { - return Err(DbErrorKind::IncompleteDatabase( - maybe_acc.address().address.clone(), - ) - .into()); - } - } - - let entry_guard = RwLockReadGuard::map( - RwLockWriteGuard::downgrade(cache_write_lock), - |cache| cache.get(address).unwrap(), - ); - - Ok(if entry_guard.account.is_some() { - Some(as_account_guard(entry_guard)) - } else { - None - }) - } - - fn should_update_cache( - require: RequireCache, account: &OverlayAccount, - ) -> bool { - trace!("update_account_cache account={:?}", account); - match require { - RequireCache::None => false, - RequireCache::Code => !account.is_code_loaded(), - RequireCache::DepositList => account.deposit_list().is_none(), - RequireCache::VoteStakeList => account.vote_stake_list().is_none(), - } - } -} - -impl State { - pub fn write_account_lock( - &self, address: &AddressWithSpace, - ) -> DbResult { - self.require_exists(address, false) - } - - pub(super) fn write_native_account_lock( - &self, address: &Address, - ) -> DbResult { - self.write_account_lock(&address.with_native_space()) - } - - pub(super) fn write_account_ext_lock( - &self, address: &AddressWithSpace, require: RequireCache, - ) -> DbResult { - Ok(match require { - RequireCache::None => self.require_exists(address, false)?, - RequireCache::Code => self.require_exists(address, true)?, - RequireCache::DepositList => { - let mut acc = self.require_exists(address, false)?; - acc.cache_ext_fields(true, false, &self.db)?; - acc - } - RequireCache::VoteStakeList => { - let mut acc = self.require_exists(address, false)?; - acc.cache_ext_fields(false, true, &self.db)?; - acc - } - }) - } - - pub(super) fn write_account_or_new_lock( - &self, address: &AddressWithSpace, - ) -> DbResult { - self.require_or_new_basic_account(address) - } - - fn require_exists( - &self, address: &AddressWithSpace, require_code: bool, - ) -> DbResult { - fn no_account_is_an_error( - address: &AddressWithSpace, - ) -> DbResult { - bail!(DbErrorKind::IncompleteDatabase(address.address)); - } - self.require_or_set(address, require_code, no_account_is_an_error) - } - - fn require_or_new_basic_account( - &self, address: &AddressWithSpace, - ) -> DbResult { - self.require_or_set(address, false, |address| { - // It is guaranteed that the address is valid. - - // Note that it is possible to first send money to a pre-calculated - // contract address and then deploy contracts. So we are - // going to *allow* sending to a contract address and - // use new_basic() to create a *stub* there. Because the contract - // serialization is a super-set of the normal address - // serialization, this should just work. - Ok(OverlayAccount::new_basic(address, U256::zero())) - }) - } - - fn require_or_set( - &self, address: &AddressWithSpace, require_code: bool, default: F, - ) -> DbResult - where F: FnOnce(&AddressWithSpace) -> DbResult { - let mut cache; - if !self.cache.read().contains_key(address) { - let account = self - .db - .get_account(address)? - .map(|acc| OverlayAccount::from_loaded(address, acc)); - cache = self.cache.write(); - Self::insert_cache_if_fresh_account(&mut *cache, address, account); - } else { - cache = self.cache.write(); - }; - - // Save the value before modification into the checkpoint. - if let Some(ref mut checkpoint) = self.checkpoints.write().last_mut() { - checkpoint.entry(*address).or_insert_with(|| { - cache.get(address).map(AccountEntry::clone_dirty) - }); - } - - let entry = (*cache) - .get_mut(address) - .expect("entry known to exist in the cache"); - - // Set the dirty flag. - entry.state = AccountState::Dirty; - - if entry.account.is_none() { - entry.account = Some(default(address)?); - } - - if require_code { - if !Self::should_update_account_cache( - RequireCache::Code, - entry - .account - .as_mut() - .expect("Required account must exist."), - &self.db, - )? { - bail!(DbErrorKind::IncompleteDatabase(address.address)); - } - } - - Ok(RwLockWriteGuard::map(cache, |c| { - c.get_mut(address) - .expect("Entry known to exist in the cache.") - .account - .as_mut() - .expect("Required account must exist.") - })) - } -} - -impl State { - fn insert_cache_if_fresh_account( - cache: &mut HashMap, - address: &AddressWithSpace, maybe_account: Option, - ) -> bool - { - if !cache.contains_key(address) { - cache.insert(*address, AccountEntry::new_clean(maybe_account)); - true - } else { - false - } - } - - /// Load required account data from the databases. Returns whether the - /// cache succeeds. - fn should_update_account_cache( - require: RequireCache, account: &mut OverlayAccount, db: &StateDb, - ) -> DbResult { - match require { - RequireCache::None => Ok(true), - RequireCache::Code => account.cache_code(db), - RequireCache::DepositList => account.cache_ext_fields( - true, /* cache_deposit_list */ - false, /* cache_vote_list */ - db, - ), - RequireCache::VoteStakeList => account.cache_ext_fields( - false, /* cache_deposit_list */ - true, /* cache_vote_list */ - db, - ), - } - } -} diff --git a/core/src/state/state_object/checkpoints.rs b/core/src/state/state_object/checkpoints.rs deleted file mode 100644 index 02a607a668..0000000000 --- a/core/src/state/state_object/checkpoints.rs +++ /dev/null @@ -1,81 +0,0 @@ -use super::State; -use std::collections::{hash_map::Entry, HashMap}; - -impl State { - /// Create a recoverable checkpoint of this state. Return the checkpoint - /// index. The checkpoint records any old value which is alive at the - /// creation time of the checkpoint and updated after that and before - /// the creation of the next checkpoint. - pub fn checkpoint(&mut self) -> usize { - self.global_stat_checkpoints - .get_mut() - .push(self.global_stat.clone()); - let checkpoints = self.checkpoints.get_mut(); - let index = checkpoints.len(); - checkpoints.push(HashMap::new()); - index - } - - /// Merge last checkpoint with previous. - /// Caller should make sure the function - /// `collect_ownership_changed()` was called before calling - /// this function. - pub fn discard_checkpoint(&mut self) { - // merge with previous checkpoint - let last = self.checkpoints.get_mut().pop(); - if let Some(mut checkpoint) = last { - self.global_stat_checkpoints.get_mut().pop(); - if let Some(ref mut prev) = self.checkpoints.get_mut().last_mut() { - if prev.is_empty() { - **prev = checkpoint; - } else { - for (k, v) in checkpoint.drain() { - prev.entry(k).or_insert(v); - } - } - } - } - } - - /// Revert to the last checkpoint and discard it. - pub fn revert_to_checkpoint(&mut self) { - if let Some(mut checkpoint) = self.checkpoints.get_mut().pop() { - self.global_stat = self - .global_stat_checkpoints - .get_mut() - .pop() - .expect("staking_state_checkpoint should exist"); - for (k, v) in checkpoint.drain() { - match v { - Some(v) => match self.cache.get_mut().entry(k) { - Entry::Occupied(mut e) => { - e.get_mut().overwrite_with(v); - } - Entry::Vacant(e) => { - e.insert(v); - } - }, - None => { - if let Entry::Occupied(e) = - self.cache.get_mut().entry(k) - { - if e.get().is_dirty() { - e.remove(); - } - } - } - } - } - } - } - - #[cfg(any(test, feature = "testonly_code"))] - pub fn clear(&mut self) { - use super::GlobalStat; - - assert!(self.checkpoints.get_mut().is_empty()); - assert!(self.global_stat_checkpoints.get_mut().is_empty()); - self.cache.get_mut().clear(); - self.global_stat = GlobalStat::loaded(&self.db).expect("no db error"); - } -} diff --git a/core/src/state/state_object/commit.rs b/core/src/state/state_object/commit.rs deleted file mode 100644 index ade5b83cb4..0000000000 --- a/core/src/state/state_object/commit.rs +++ /dev/null @@ -1,113 +0,0 @@ -use super::{AccountState, State}; -use cfx_internal_common::{ - debug::ComputeEpochDebugRecord, StateRootWithAuxInfo, -}; -use cfx_statedb::Result as DbResult; -use cfx_storage::utils::access_mode; -use cfx_types::AddressWithSpace; -use primitives::{Account, EpochId, StorageKey}; - -impl State { - // It's guaranteed that the second call of this method is a no-op. - pub fn compute_state_root( - &mut self, mut debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> DbResult { - debug!("state.compute_state_root"); - - assert!(self.checkpoints.get_mut().is_empty()); - assert!(self.global_stat_checkpoints.get_mut().is_empty()); - - let mut sorted_dirty_accounts = - self.cache.get_mut().drain().collect::>(); - sorted_dirty_accounts.sort_by(|a, b| a.0.cmp(&b.0)); - - let mut killed_addresses = Vec::new(); - for (address, entry) in sorted_dirty_accounts.iter_mut() { - entry.state = AccountState::Committed; - match &mut entry.account { - None => {} - Some(account) if account.removed_without_update() => { - killed_addresses.push(*address); - // TODO: seems useless - self.accounts_to_notify.push(Err(*address)); - } - Some(account) => { - if account.invalidated_storage() { - self.recycle_storage( - vec![*account.address()], - debug_record.as_deref_mut(), - )?; - } - account.commit( - &mut self.db, - address, - debug_record.as_deref_mut(), - )?; - self.accounts_to_notify.push(Ok(account.as_account())); - } - } - } - self.recycle_storage(killed_addresses, debug_record.as_deref_mut())?; - self.global_stat - .commit(&mut self.db, debug_record.as_deref_mut())?; - self.db.compute_state_root(debug_record) - } - - pub fn commit( - &mut self, epoch_id: EpochId, - mut debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> DbResult - { - debug!("Commit epoch[{}]", epoch_id); - self.compute_state_root(debug_record.as_deref_mut())?; - Ok(self.db.commit(epoch_id, debug_record)?) - } - - pub fn accounts_for_txpool(&self) -> Vec { - self.accounts_to_notify - .iter() - .filter_map(|x| match x { - Ok(account) => Some(account.clone()), - _ => None, - }) - .collect() - } - - /// Assume that only contract with zero `collateral_for_storage` will be - /// killed. - fn recycle_storage( - &mut self, killed_addresses: Vec, - mut debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> DbResult<()> - { - // TODO: Think about kill_dust and collateral refund. - for address in &killed_addresses { - self.db.delete_all::( - StorageKey::new_storage_root_key(&address.address) - .with_space(address.space), - debug_record.as_deref_mut(), - )?; - self.db.delete_all::( - StorageKey::new_code_root_key(&address.address) - .with_space(address.space), - debug_record.as_deref_mut(), - )?; - self.db.delete( - StorageKey::new_account_key(&address.address) - .with_space(address.space), - debug_record.as_deref_mut(), - )?; - self.db.delete( - StorageKey::new_deposit_list_key(&address.address) - .with_space(address.space), - debug_record.as_deref_mut(), - )?; - self.db.delete( - StorageKey::new_vote_list_key(&address.address) - .with_space(address.space), - debug_record.as_deref_mut(), - )?; - } - Ok(()) - } -} diff --git a/core/src/state/state_object/mod.rs b/core/src/state/state_object/mod.rs deleted file mode 100644 index 0c1eb74f42..0000000000 --- a/core/src/state/state_object/mod.rs +++ /dev/null @@ -1,96 +0,0 @@ -macro_rules! try_loaded { - ($expr:expr) => { - match $expr { - Err(e) => { - return Err(e); - } - Ok(None) => { - return Ok(Default::default()); - } - Ok(Some(v)) => v, - } - }; -} - -macro_rules! noop_if { - ($expr:expr) => { - if $expr { - return Ok(Default::default()); - } - }; -} - -mod account_controller; -mod basic_fields; -mod cache_layer; -mod checkpoints; -mod collateral; -mod commit; -mod global_statistics; -mod pos; -mod sponsor; -mod staking; -mod storage_entry; -#[cfg(test)] -mod tests; - -use self::cache_layer::RequireCache; -use super::{ - account_entry::{AccountEntry, AccountState}, - global_stat::GlobalStat, - overlay_account::OverlayAccount, - substate, AccountEntryProtectedMethods, -}; -use crate::{executive::internal_contract, vm::Spec}; -use cfx_state::tracer::StateTracer; -use cfx_statedb::{Result as DbResult, StateDbExt, StateDbGeneric as StateDb}; -use cfx_types::AddressWithSpace; -use parking_lot::RwLock; -use primitives::Account; -use std::collections::HashMap; - -pub use self::{ - collateral::settle_collateral_for_all, - pos::{distribute_pos_interest, update_pos_status}, - staking::initialize_or_update_dao_voted_params, -}; - -pub struct State { - pub(super) db: StateDb, - - // Only created once for txpool notification. - // Each element is an Ok(Account) for updated account, or - // Err(AddressWithSpace) for deleted account. - accounts_to_notify: Vec>, - - // Contains the changes to the states and some unchanged state entries. - cache: RwLock>, - // TODO: try not to make it special? - global_stat: GlobalStat, - - // Checkpoint to the changes. - global_stat_checkpoints: RwLock>, - checkpoints: RwLock>>>, -} - -impl State { - pub fn new(db: StateDb) -> DbResult { - let initialized = db.is_initialized()?; - - let world_stat = if initialized { - GlobalStat::loaded(&db)? - } else { - GlobalStat::assert_non_inited(&db)?; - GlobalStat::new() - }; - - Ok(State { - db, - cache: Default::default(), - global_stat_checkpoints: Default::default(), - checkpoints: Default::default(), - global_stat: world_stat, - accounts_to_notify: Default::default(), - }) - } -} diff --git a/core/src/state/state_object/sponsor.rs b/core/src/state/state_object/sponsor.rs deleted file mode 100644 index 1b1894bf2f..0000000000 --- a/core/src/state/state_object/sponsor.rs +++ /dev/null @@ -1,328 +0,0 @@ -use cfx_parameters::{ - internal_contract_addresses::SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS, - staking::COLLATERAL_UNITS_PER_STORAGE_KEY, -}; -use cfx_state::maybe_address; -use cfx_statedb::{ - global_params::{ConvertedStoragePoints, TotalIssued}, - Result as DbResult, -}; -use cfx_storage::utils::access_mode; -use cfx_types::{Address, AddressSpaceUtil, Space, U256}; -use primitives::{ - SkipInputCheck, SponsorInfo, StorageKey, StorageKeyWithSpace, StorageValue, -}; -use std::collections::HashMap; - -use super::{internal_contract::storage_point_prop, substate::Substate, State}; - -impl State { - pub fn sponsor_info( - &self, address: &Address, - ) -> DbResult> { - let acc = try_loaded!(self.read_native_account_lock(address)); - Ok(Some(acc.sponsor_info().clone())) - } - - // Sponsor for gas - - pub fn sponsor_for_gas( - &self, address: &Address, - ) -> DbResult> { - let acc = try_loaded!(self.read_native_account_lock(address)); - Ok(maybe_address(&acc.sponsor_info().sponsor_for_gas)) - } - - pub fn set_sponsor_for_gas( - &self, address: &Address, sponsor: &Address, sponsor_balance: &U256, - upper_bound: &U256, - ) -> DbResult<()> - { - let sponsor_not_change = - *sponsor == self.sponsor_for_gas(address)?.unwrap_or_default(); - let balance_not_change = - *sponsor_balance == self.sponsor_balance_for_gas(address)?; - noop_if!(sponsor_not_change && balance_not_change); - - self.write_native_account_lock(&address)? - .set_sponsor_for_gas(sponsor, sponsor_balance, upper_bound); - Ok(()) - } - - // Sponsor balance for gas - - pub fn sponsor_balance_for_gas(&self, address: &Address) -> DbResult { - let acc = try_loaded!(self.read_native_account_lock(address)); - Ok(acc.sponsor_info().sponsor_balance_for_gas) - } - - pub fn add_sponsor_balance_for_gas( - &mut self, address: &Address, by: &U256, - ) -> DbResult<()> { - noop_if!(by.is_zero()); - - self.write_native_account_lock(&address)? - .add_sponsor_balance_for_gas(by); - Ok(()) - } - - pub fn sub_sponsor_balance_for_gas( - &mut self, address: &Address, by: &U256, - ) -> DbResult<()> { - noop_if!(by.is_zero()); - - self.write_native_account_lock(&address)? - .sub_sponsor_balance_for_gas(by); - Ok(()) - } - - // Sponsor gas bound - - pub fn sponsor_gas_bound(&self, address: &Address) -> DbResult { - let acc = try_loaded!(self.read_native_account_lock(address)); - Ok(acc.sponsor_info().sponsor_gas_bound) - } - - // Sponsor for collateral - - pub fn sponsor_for_collateral( - &self, address: &Address, - ) -> DbResult> { - let acc = try_loaded!(self.read_native_account_lock(address)); - Ok(maybe_address(&acc.sponsor_info().sponsor_for_collateral)) - } - - pub fn set_sponsor_for_collateral( - &mut self, address: &Address, sponsor: &Address, - sponsor_balance: &U256, is_cip107: bool, - ) -> DbResult - { - let sponsor_not_change = *sponsor - == self.sponsor_for_collateral(address)?.unwrap_or_default(); - let balance_not_change = - *sponsor_balance == self.sponsor_balance_for_collateral(address)?; - noop_if!(sponsor_not_change && balance_not_change); - - let prop = if is_cip107 { - self.get_system_storage(&storage_point_prop())? - } else { - U256::zero() - }; - - let converted_storage_points = self - .write_native_account_lock(&address)? - .set_sponsor_for_collateral(sponsor, sponsor_balance, prop); - - *self.global_stat.val::() -= converted_storage_points; - *self.global_stat.val::() += - converted_storage_points; - Ok(converted_storage_points) - } - - // Sponsor balance for collateral - - pub fn sponsor_balance_for_collateral( - &self, address: &Address, - ) -> DbResult { - let acc = try_loaded!(self.read_native_account_lock(address)); - Ok(acc.sponsor_info().sponsor_balance_for_collateral) - } - - pub fn add_sponsor_balance_for_collateral( - &mut self, address: &Address, by: &U256, - ) -> DbResult<()> { - noop_if!(by.is_zero()); - - self.write_native_account_lock(&address)? - .add_sponsor_balance_for_collateral(by); - Ok(()) - } - - pub fn sub_sponsor_balance_for_collateral( - &mut self, address: &Address, by: &U256, - ) -> DbResult<()> { - noop_if!(by.is_zero()); - - self.write_native_account_lock(&address)? - .sub_sponsor_balance_for_collateral(by); - - Ok(()) - } - - // Whitelist - - pub fn check_contract_whitelist( - &self, contract_address: &Address, user: &Address, - ) -> DbResult { - let acc = try_loaded!(self.read_native_account_lock( - &SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS - )); - acc.check_contract_whitelist(&self.db, contract_address, user) - } - - pub fn add_to_contract_whitelist( - &mut self, contract_address: Address, contract_owner: Address, - user: Address, - ) -> DbResult<()> - { - info!("add_commission_privilege contract_address: {:?}, contract_owner: {:?}, user: {:?}", contract_address, contract_owner, user); - - self.write_native_account_lock( - &SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS, - )? - .add_to_contract_whitelist( - contract_address, - contract_owner, - user, - ); - - Ok(()) - } - - pub fn remove_from_contract_whitelist( - &mut self, contract_address: Address, contract_owner: Address, - user: Address, - ) -> DbResult<()> - { - self.write_native_account_lock( - &SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS, - )? - .remove_from_contract_whitelist( - contract_address, - contract_owner, - user, - ); - Ok(()) - } - - pub fn clear_contract_whitelist( - &mut self, address: &Address, - ) -> DbResult, Address>> { - let mut storage_owner_map = HashMap::new(); - let key_values = self.db.delete_all::( - StorageKey::new_storage_key( - &SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS, - address.as_ref(), - ) - .with_native_space(), - /* debug_record = */ None, - )?; - for (key, value) in &key_values { - if let StorageKeyWithSpace { - key: StorageKey::StorageKey { storage_key, .. }, - space, - } = - StorageKeyWithSpace::from_key_bytes::(&key[..]) - { - assert_eq!(space, Space::Native); - let storage_value = - rlp::decode::(value.as_ref())?; - let storage_owner = storage_value - .owner - .unwrap_or(SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS); - storage_owner_map.insert(storage_key.to_vec(), storage_owner); - } - } - - let mut sponsor_internal_contract = self.write_native_account_lock( - &SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS, - )?; - // Then scan storage changes in cache. - for (key, _value) in - sponsor_internal_contract.storage_value_write_cache() - { - if key.starts_with(address.as_ref()) { - if let Some(storage_owner) = sponsor_internal_contract - .original_ownership_at(&self.db, key)? - { - storage_owner_map.insert(key.clone(), storage_owner); - } else { - // The corresponding entry has been reset during transaction - // execution, so we do not need to handle it now. - storage_owner_map.remove(key); - } - } - } - if !AM::READ_ONLY { - // Note removal of all keys in storage_value_read_cache and - // storage_value_write_cache. - for (key, _storage_owner) in &storage_owner_map { - debug!("delete sponsor key {:?}", key); - sponsor_internal_contract.set_storage( - key.clone(), - U256::zero(), - /* owner doesn't matter for 0 value */ - Address::zero(), - ); - } - } - - Ok(storage_owner_map) - } - - pub fn record_storage_and_whitelist_entries_release( - &mut self, address: &Address, substate: &mut Substate, - ) -> DbResult<()> { - self.clear_contract_whitelist::(address)?; - - // Process collateral for removed storage. - // TODO: try to do it in a better way, e.g. first log the deletion - // somewhere then apply the collateral change. - - self.write_native_account_lock( - &SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS, - )? - .commit_ownership_change(&self.db, substate)?; - - let account_cache_read_guard = self.cache.read(); - let maybe_account = account_cache_read_guard - .get(&address.with_native_space()) - .and_then(|acc| acc.account.as_ref()); - - let storage_key_value = self.db.delete_all::( - StorageKey::new_storage_root_key(address).with_native_space(), - None, - )?; - for (key, value) in &storage_key_value { - if let StorageKeyWithSpace { - key: StorageKey::StorageKey { storage_key, .. }, - space, - } = - StorageKeyWithSpace::from_key_bytes::(&key[..]) - { - assert_eq!(space, Space::Native); - // Check if the key has been touched. We use the local - // information to find out if collateral refund is necessary - // for touched keys. - if maybe_account.map_or(true, |acc| { - acc.storage_value_write_cache().get(storage_key).is_none() - }) { - let storage_value = - rlp::decode::(value.as_ref())?; - // Must native space - let storage_owner = - storage_value.owner.as_ref().unwrap_or(address); - substate.record_storage_release( - storage_owner, - COLLATERAL_UNITS_PER_STORAGE_KEY, - ); - } - } - } - - if let Some(acc) = maybe_account { - // The current value isn't important because it will be deleted. - for (key, _value) in acc.storage_value_write_cache() { - if let Some(storage_owner) = - acc.original_ownership_at(&self.db, key)? - { - substate.record_storage_release( - &storage_owner, - COLLATERAL_UNITS_PER_STORAGE_KEY, - ); - } - } - } - Ok(()) - } -} diff --git a/core/src/state/trace.rs b/core/src/state/trace.rs deleted file mode 100644 index fbbd1812ff..0000000000 --- a/core/src/state/trace.rs +++ /dev/null @@ -1,55 +0,0 @@ -use cfx_state::tracer::{AddressPocket::*, StateTracer}; -use cfx_types::{address_util::AddressUtil, Address, AddressSpaceUtil, U256}; - -pub fn trace_convert_stroage_points( - tracer: &mut dyn StateTracer, addr: Address, from_balance: U256, - from_collateral: U256, -) -{ - if !from_balance.is_zero() { - tracer.trace_internal_transfer( - SponsorBalanceForStorage(addr), - MintBurn, - from_balance, - ); - } - if !from_collateral.is_zero() { - tracer.trace_internal_transfer( - StorageCollateral(addr), - MintBurn, - from_collateral, - ); - } -} - -pub fn trace_refund_collateral( - tracer: &mut dyn StateTracer, addr: Address, by: U256, -) { - if !by.is_zero() { - tracer.trace_internal_transfer( - StorageCollateral(addr), - if addr.is_contract_address() { - SponsorBalanceForStorage(addr) - } else { - Balance(addr.with_native_space()) - }, - by, - ); - } -} - -pub fn trace_occupy_collateral( - tracer: &mut dyn StateTracer, addr: Address, by: U256, -) { - if !by.is_zero() { - tracer.trace_internal_transfer( - if addr.is_contract_address() { - SponsorBalanceForStorage(addr) - } else { - Balance(addr.with_native_space()) - }, - StorageCollateral(addr), - by, - ); - } -} diff --git a/core/state/Cargo.toml b/core/state/Cargo.toml deleted file mode 100644 index a4a2ad80f8..0000000000 --- a/core/state/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -description = "Conflux core state library" -homepage = "https://www.confluxnetwork.org" -license = "GPL-3.0" -name = "cfx-state" -version = "1.0.0" -edition = "2018" - -[dependencies] -cfx-internal-common = { path = "../internal_common" } -cfx-parameters = { path = "../parameters" } -cfx-storage = { path = "../storage" } -cfx-statedb = { path = "../statedb" } -cfx-types = { path = "../../cfx_types" } -parking_lot = "0.11" -primitives = { path = "../../primitives", optional = true } -# TODO: update all rlp version. -rlp = "0.4" -keccak-hash = "0.5" - -[dev-dependencies] -primitives = { path = "../../primitives", features = ["test_no_account_length_check"] } - -[features] -default = ["primitives"] -# Unfortunately cfg test attributes doesn't work across crates, -# we have to define a feature for test code. -# https://users.rust-lang.org/t/cfg-test-doesnt-propagate-to-external-crates/13046 -testonly_code = [] -new_state_impl = [] diff --git a/core/state/src/cache_object.rs b/core/state/src/cache_object.rs deleted file mode 100644 index 270bebc543..0000000000 --- a/core/state/src/cache_object.rs +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright 2021 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -pub trait CachedObject: Encodable + IsDefault + Sized { - type HashKeyType: AsStorageKey; - - fn load_from_rlp(key: &Self::HashKeyType, rlp: &Rlp) -> Result; - - fn load( - key: &Self::HashKeyType, db: &StateDb, - ) -> Result> { - match db.get_raw(key.storage_key()) { - Err(e) => Err(e), - Ok(None) => Ok(None), - Ok(Some(v)) => Ok(Some(Self::load_from_rlp(key, &Rlp::new(&v))?)), - } - } - - // This method also checks if the value IsDefault, if so map the update to a - // deletion. - fn update( - &self, key: &Self::HashKeyType, db: &mut StateDb, - debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result<()> - { - if self.is_default() { - db.delete(key.storage_key(), debug_record) - } else { - db.set(key.storage_key(), self, debug_record) - } - } - - fn delete( - key: &Self::HashKeyType, db: &mut StateDb, - debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result<()> - { - db.delete(key.storage_key(), debug_record) - } -} - -/// Account address and code hash. -#[derive(Clone, Eq, Hash, PartialEq)] -pub struct CodeAddress(pub Address, pub H256); - -/// Contract address and user address. -#[derive(Clone, Eq, Hash, PartialEq)] -pub struct CommissionPrivilegeAddress(pub Vec); - -impl CommissionPrivilegeAddress { - pub fn new( - contract_address: Address, user_address: Address, - ) -> CommissionPrivilegeAddress { - let mut key = Vec::with_capacity(Address::len_bytes() * 2); - key.extend_from_slice(contract_address.as_ref()); - key.extend_from_slice(user_address.as_ref()); - CommissionPrivilegeAddress(key) - } -} - -#[derive(Clone, Eq, Hash, PartialEq)] -pub struct DepositListAddress(pub Address); - -#[derive(Clone, Eq, Hash, PartialEq)] -pub struct VoteStakeListAddress(pub Address); - -pub struct CachedAccount { - object: Account, -} - -impl CachedAccount { - pub fn new_basic(address: &Address, balance: &U256, nonce: &U256) -> Self { - Self { - object: Account::new_empty_with_balance(address, balance, nonce), - } - } -} - -pub struct CachedCommissionPrivilege { - has_privilege: bool, -} - -impl CachedCommissionPrivilege { - pub fn new(has_privilege: bool) -> CachedCommissionPrivilege { - CachedCommissionPrivilege { has_privilege } - } - - pub fn has_privilege(&self) -> bool { self.has_privilege } - - pub fn add_privilege(&mut self) { self.has_privilege = true; } - - pub fn remove_privilege(&mut self) { self.has_privilege = false; } -} - -#[derive(Clone, Eq, Hash, PartialEq)] -pub struct StorageAddress(pub Address, pub Vec); - -pub trait ToHashKey { - fn to_hash_key(&self) -> K; -} - -pub trait AsStorageKey { - fn storage_key(&self) -> StorageKey; -} - -impl AsStorageKey for Address { - fn storage_key(&self) -> StorageKey { - StorageKey::AccountKey(self.0.as_ref()) - } -} - -impl ToHashKey
for Address { - fn to_hash_key(&self) -> Self { self.clone() } -} - -impl AsStorageKey for CodeAddress { - fn storage_key(&self) -> StorageKey { - StorageKey::CodeKey { - address_bytes: self.0.as_ref(), - code_hash_bytes: self.1.as_ref(), - } - } -} - -impl ToHashKey for CodeAddress { - fn to_hash_key(&self) -> CodeAddress { self.clone() } -} - -impl AsStorageKey for CommissionPrivilegeAddress { - fn storage_key(&self) -> StorageKey { - StorageKey::StorageKey { - address_bytes: SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS.as_ref(), - storage_key: self.0.as_ref(), - } - } -} - -impl ToHashKey for CommissionPrivilegeAddress { - fn to_hash_key(&self) -> Self { self.clone() } -} - -impl AsStorageKey for DepositListAddress { - fn storage_key(&self) -> StorageKey { - StorageKey::DepositListKey(self.0.as_ref()) - } -} - -impl ToHashKey for DepositListAddress { - fn to_hash_key(&self) -> Self { self.clone() } -} - -impl AsStorageKey for VoteStakeListAddress { - fn storage_key(&self) -> StorageKey { - StorageKey::VoteListKey(self.0.as_ref()) - } -} - -impl ToHashKey for VoteStakeListAddress { - fn to_hash_key(&self) -> Self { self.clone() } -} - -impl AsStorageKey for StorageAddress { - fn storage_key(&self) -> StorageKey { - StorageKey::StorageKey { - address_bytes: self.0.as_ref(), - storage_key: self.1.as_ref(), - } - } -} - -impl ToHashKey for StorageAddress { - fn to_hash_key(&self) -> Self { self.clone() } -} - -impl CachedObject for CachedAccount { - type HashKeyType = Address; - - fn load_from_rlp(key: &Address, rlp: &Rlp) -> Result { - Ok(Self { - object: Account::new_from_rlp(key.clone(), rlp)?, - }) - } -} - -impl CachedObject for CodeInfo { - type HashKeyType = CodeAddress; - - fn load_from_rlp(_key: &CodeAddress, rlp: &Rlp) -> Result { - Ok(Self::decode(rlp)?) - } -} - -impl CachedObject for CachedCommissionPrivilege { - type HashKeyType = CommissionPrivilegeAddress; - - fn load_from_rlp( - _key: &CommissionPrivilegeAddress, rlp: &Rlp, - ) -> Result { - Ok(Self { - has_privilege: bool::decode(rlp)?, - }) - } -} - -impl CachedObject for DepositList { - type HashKeyType = DepositListAddress; - - fn load_from_rlp(_key: &DepositListAddress, rlp: &Rlp) -> Result { - Ok(Self::decode(rlp)?) - } -} - -impl CachedObject for VoteStakeList { - type HashKeyType = VoteStakeListAddress; - - fn load_from_rlp(_key: &VoteStakeListAddress, rlp: &Rlp) -> Result { - Ok(Self::decode(rlp)?) - } -} - -impl CachedObject for StorageValue { - type HashKeyType = StorageAddress; - - fn load_from_rlp(_key: &StorageAddress, rlp: &Rlp) -> Result { - Ok(Self::decode(rlp)?) - } -} - -impl Deref for CachedAccount { - type Target = Account; - - fn deref(&self) -> &Self::Target { &self.object } -} - -impl DerefMut for CachedAccount { - fn deref_mut(&mut self) -> &mut Self::Target { &mut self.object } -} - -impl Encodable for CachedAccount { - fn rlp_append(&self, s: &mut RlpStream) { s.append_internal(&self.object); } -} - -impl IsDefault for CachedAccount { - fn is_default(&self) -> bool { self.object.is_default() } -} - -impl Deref for CachedCommissionPrivilege { - type Target = bool; - - fn deref(&self) -> &Self::Target { &self.has_privilege } -} - -impl DerefMut for CachedCommissionPrivilege { - fn deref_mut(&mut self) -> &mut Self::Target { &mut self.has_privilege } -} - -impl Encodable for CachedCommissionPrivilege { - fn rlp_append(&self, s: &mut RlpStream) { - s.append_internal(&self.has_privilege); - } -} - -impl IsDefault for CachedCommissionPrivilege { - fn is_default(&self) -> bool { self.has_privilege.is_default() } -} - -use crate::StateDbOps; -use cfx_internal_common::debug::ComputeEpochDebugRecord; -use cfx_statedb::Result; -use cfx_types::{Address, H256, U256}; -use primitives::{ - is_default::IsDefault, Account, CodeInfo, DepositList, StorageKey, - StorageValue, VoteStakeList, -}; -use rlp::{Decodable, Encodable, Rlp, RlpStream}; -use std::ops::{Deref, DerefMut}; - -use cfx_parameters::internal_contract_addresses::SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS; diff --git a/core/state/src/lib.rs b/core/state/src/lib.rs deleted file mode 100644 index 886532a85b..0000000000 --- a/core/state/src/lib.rs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2021 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -#[cfg(feature = "new_state_impl")] -pub(self) mod cache_object; -#[cfg(feature = "new_state_impl")] -pub mod state; -#[cfg(feature = "new_state_impl")] -pub(self) mod state_object_cache; -pub mod tracer; - -#[derive(Copy, Clone, PartialEq, Debug)] -pub enum CollateralCheckResult { - ExceedStorageLimit { limit: U256, required: U256 }, - NotEnoughBalance { required: U256, got: U256 }, - Valid, -} - -impl CollateralCheckResult { - pub fn ok(&self) -> bool { *self == CollateralCheckResult::Valid } -} - -/// Mode of dealing with null accounts. -#[derive(PartialEq)] -pub enum CleanupMode<'a> { - /// Create accounts which would be null. - ForceCreate, - /// Don't delete null accounts upon touching, but also don't create them. - NoEmpty, - /// Mark all touched accounts. - /// TODO: We have not implemented the correct behavior of TrackTouched for - /// internal Contracts. - TrackTouched(&'a mut HashSet), -} - -pub fn maybe_address(address: &Address) -> Option
{ - if address.is_zero() { - None - } else { - Some(*address) - } -} - -// TODO: Deprecate the StateDbExt in StateDb and replace it with StateDbOps. -pub trait StateDbOps { - fn get_raw(&self, key: StorageKeyWithSpace) -> Result>>; - - fn get(&self, key: StorageKeyWithSpace) -> Result> - where T: ::rlp::Decodable; - - fn set( - &mut self, key: StorageKeyWithSpace, value: &T, - debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result<()> - where - T: ::rlp::Encodable + IsDefault; - - fn delete( - &mut self, key: StorageKeyWithSpace, - debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result<()>; -} - -impl StateDbOps for StateDbGeneric { - fn get_raw(&self, key: StorageKeyWithSpace) -> Result>> { - Self::get_raw(self, key) - } - - fn get(&self, key: StorageKeyWithSpace) -> Result> - where T: ::rlp::Decodable { - ::get(self, key) - } - - fn set( - &mut self, key: StorageKeyWithSpace, value: &T, - debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result<()> - where - T: ::rlp::Encodable + IsDefault, - { - ::set(self, key, value, debug_record) - } - - fn delete( - &mut self, key: StorageKeyWithSpace, - debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result<()> - { - Self::delete(self, key, debug_record) - } -} - -use cfx_internal_common::debug::ComputeEpochDebugRecord; -use cfx_statedb::{Result, StateDbExt, StateDbGeneric}; -use cfx_types::{Address, AddressWithSpace, U256}; -use primitives::{is_default::IsDefault, StorageKeyWithSpace}; -use std::{collections::HashSet, sync::Arc}; diff --git a/core/state/src/state.rs b/core/state/src/state.rs deleted file mode 100644 index bbcee2b71e..0000000000 --- a/core/state/src/state.rs +++ /dev/null @@ -1,816 +0,0 @@ -// Copyright 2021 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -use cfx_types::U256; - -pub struct State { - db: StateDbGeneric, - - // State entries object-cache. - cache: StateObjectCache, - - // A marker for the bound substate type. - _substate_marker: PhantomData, -} - -impl StateTrait - for State -{ - type Substate = Substate; - - fn collect_ownership_changed( - &mut self, _substate: &mut Self::Substate, - ) -> Result<()> { - unimplemented!() - } - - fn settle_collateral_for_all( - &mut self, _substate: &Self::Substate, _account_start_nonce: U256, - ) -> Result { - unimplemented!() - } - - fn collect_and_settle_collateral( - &mut self, _original_sender: &Address, _storage_limit: &U256, - _substate: &mut Self::Substate, _account_start_nonce: U256, - ) -> Result - { - unimplemented!() - } - - fn record_storage_and_whitelist_entries_release( - &mut self, _address: &Address, _substate: &mut Self::Substate, - ) -> Result<()> { - unimplemented!() - } - - fn compute_state_root( - &mut self, debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result { - self.db.compute_state_root(debug_record) - } - - fn commit( - &mut self, epoch_id: EpochId, - debug_record: Option<&mut ComputeEpochDebugRecord>, - ) -> Result - { - self.db.commit(epoch_id, debug_record) - } -} - -impl - CheckpointTrait for State -{ - fn checkpoint(&mut self) -> usize { self.db.checkpoint() } - - fn discard_checkpoint(&mut self) { self.db.discard_checkpoint(); } - - fn revert_to_checkpoint(&mut self) { - // Drop the cache because of the revert. - self.cache.clear(); - self.db.revert_to_checkpoint(); - } -} - -impl - StateOpsTrait for State -{ - fn bump_block_number_accumulate_interest(&mut self) -> U256 { - unimplemented!() - } - - fn add_total_issued(&mut self, v: U256) { - let new_total_issued = self.total_issued_tokens() + v; - self.set_storage( - &STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS, - TOTAL_TOKENS_KEY.to_vec(), - new_total_issued, - *STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS, - ) - .unwrap(); - } - - fn subtract_total_issued(&mut self, v: U256) { - let new_total_issued = self.total_issued_tokens() - v; - self.set_storage( - &STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS, - TOTAL_TOKENS_KEY.to_vec(), - new_total_issued, - *STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS, - ) - .unwrap(); - } - - fn add_total_pos_staking(&mut self, _v: U256) { unimplemented!() } - - fn inc_distributable_pos_interest( - &mut self, _current_block_number: u64, - ) -> Result<()> { - unimplemented!() - } - - fn distribute_pos_interest<'a>( - &mut self, _pos_points: Box + 'a>, - _account_start_nonce: U256, _current_block_number: u64, - ) -> Result> - { - unimplemented!() - } - - fn new_contract_with_admin( - &mut self, _contract: &Address, _admin: &Address, _balance: U256, - _nonce: U256, _storage_layout: Option, cip107: bool, - ) -> Result<()> - { - unimplemented!() - } - - fn balance(&self, address: &Address) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.balance) - .unwrap_or_default()) - } - - fn is_contract_with_code(&self, address: &Address) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map_or(false, |a| a.code_hash != KECCAK_EMPTY)) - } - - fn sponsor_for_gas(&self, address: &Address) -> Result> { - Ok(self - .get_account(address)? - .as_ref() - .map_or(None, |a| maybe_address(&a.sponsor_info.sponsor_for_gas))) - } - - fn sponsor_for_collateral( - &self, address: &Address, - ) -> Result> { - Ok(self.get_account(address)?.as_ref().map_or(None, |a| { - maybe_address(&a.sponsor_info.sponsor_for_collateral) - })) - } - - fn set_sponsor_for_gas( - &self, _address: &Address, _sponsor: &Address, _sponsor_balance: &U256, - _upper_bound: &U256, - ) -> Result<()> - { - unimplemented!() - } - - fn set_sponsor_for_collateral( - &self, _address: &Address, _sponsor: &Address, _sponsor_balance: &U256, - ) -> Result<()> { - unimplemented!() - } - - fn sponsor_info(&self, address: &Address) -> Result> { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.sponsor_info.clone())) - } - - fn sponsor_gas_bound(&self, address: &Address) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.sponsor_info.sponsor_gas_bound) - .unwrap_or_default()) - } - - fn sponsor_balance_for_gas(&self, address: &Address) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.sponsor_info.sponsor_balance_for_gas) - .unwrap_or_default()) - } - - fn sponsor_balance_for_collateral( - &self, address: &Address, - ) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.sponsor_info.sponsor_balance_for_collateral) - .unwrap_or_default()) - } - - fn set_admin( - &mut self, contract_address: &Address, admin: &Address, - ) -> Result<()> { - self.modify_and_update_account(contract_address, None)? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(*contract_address).into()), - |value| { - value.admin = *admin; - Ok(()) - }, - ) - } - - fn sub_sponsor_balance_for_gas( - &mut self, address: &Address, by: &U256, - ) -> Result<()> { - if by.is_zero() { - Ok(()) - } else { - self.modify_and_update_account(address, None)? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(*address).into()), - |value| { - value.sponsor_info.sponsor_balance_for_gas -= *by; - Ok(()) - }, - ) - } - } - - fn add_sponsor_balance_for_gas( - &mut self, address: &Address, by: &U256, - ) -> Result<()> { - if by.is_zero() { - Ok(()) - } else { - self.modify_and_update_account(address, None)? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(*address).into()), - |value| { - value.sponsor_info.sponsor_balance_for_gas += *by; - Ok(()) - }, - ) - } - } - - fn sub_sponsor_balance_for_collateral( - &mut self, address: &Address, by: &U256, - ) -> Result<()> { - if by.is_zero() { - Ok(()) - } else { - self.modify_and_update_account(address, None)? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(*address).into()), - |value| { - value.sponsor_info.sponsor_balance_for_collateral -= - *by; - Ok(()) - }, - ) - } - } - - fn add_sponsor_balance_for_collateral( - &mut self, address: &Address, by: &U256, - ) -> Result<()> { - if by.is_zero() { - Ok(()) - } else { - self.modify_and_update_account(address, None)? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(*address).into()), - |value| { - value.sponsor_info.sponsor_balance_for_collateral += - *by; - Ok(()) - }, - ) - } - } - - fn check_commission_privilege( - &self, contract_address: &Address, user_address: &Address, - ) -> Result { - Ok(self - .get_commission_privilege(contract_address, user_address)? - .as_ref() - .map_or(false, |value| value.has_privilege())) - } - - fn add_commission_privilege( - &mut self, contract_address: Address, _contract_owner: Address, - user: Address, - ) -> Result<()> - { - self.modify_and_update_commission_privilege( - &contract_address, - &user, - None, - )? - .as_mut() - .map_or_else( - || unreachable!(), - |value| { - value.add_privilege(); - Ok(()) - }, - ) - } - - fn remove_commission_privilege( - &mut self, contract_address: Address, _contract_owner: Address, - user: Address, - ) -> Result<()> - { - self.modify_and_update_commission_privilege( - &contract_address, - &user, - None, - )? - .as_mut() - .map_or_else( - || unreachable!(), - |value| { - value.remove_privilege(); - Ok(()) - }, - ) - } - - fn nonce(&self, address: &Address) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.nonce) - .unwrap_or_default()) - } - - fn init_code( - &mut self, address: &Address, code: Vec, owner: Address, - ) -> Result<()> { - let code_hash = keccak(&code); - - // Update the code hash. - self.modify_and_update_account(address, None)? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(*address).into()), - |value| { - value.code_hash = code_hash; - Ok(()) - }, - )?; - - // Set the code. - self.require_or_set_code(*address, owner, code, None) - } - - fn code_hash(&self, contract_address: &Address) -> Result> { - Ok(self - .get_account(contract_address)? - .as_ref() - .map(|a| a.code_hash)) - } - - fn code_size(&self, contract_address: &Address) -> Result> { - Ok(self - .get_code(contract_address)? - .as_ref() - .map(|code_info| code_info.code.len())) - } - - fn code_owner( - &self, contract_address: &Address, - ) -> Result> { - Ok(self - .get_code(contract_address)? - .as_ref() - .map(|code_info| code_info.owner)) - } - - fn code(&self, contract_address: &Address) -> Result>>> { - Ok(self - .get_code(contract_address)? - .as_ref() - .map(|code_info| code_info.code.clone())) - } - - fn staking_balance(&self, address: &Address) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.staking_balance) - .unwrap_or_default()) - } - - fn collateral_for_storage(&self, address: &Address) -> Result { - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.collateral_for_storage) - .unwrap_or_default()) - } - - fn admin(&self, address: &Address) -> Result
{ - Ok(self - .get_account(address)? - .as_ref() - .map(|a| a.admin) - .unwrap_or_default()) - } - - fn withdrawable_staking_balance( - &self, address: &Address, current_block_number: u64, - ) -> Result { - let staking_balance = self.staking_balance(address)?; - match self.get_vote_stake_list(address)?.as_ref().deref() { - None => Ok(staking_balance), - Some(vote_stake_list) => Ok(vote_stake_list - .withdrawable_staking_balance( - staking_balance, - current_block_number, - )), - } - } - - fn locked_staking_balance_at_block_number( - &self, address: &Address, current_block_number: u64, - ) -> Result { - let staking_balance = self.staking_balance(address)?; - let withdrawable_staking_balance = - self.withdrawable_staking_balance(address, current_block_number)?; - Ok(staking_balance - withdrawable_staking_balance) - } - - fn deposit_list_length(&self, address: &Address) -> Result { - Ok(self - .get_deposit_list(address)? - .as_ref() - .map_or(0, |deposit_list| deposit_list.len())) - } - - fn vote_stake_list_length(&self, address: &Address) -> Result { - Ok(self - .get_vote_stake_list(address)? - .as_ref() - .map_or(0, |vote_stake_list| vote_stake_list.len())) - } - - fn genesis_special_clean_account( - &mut self, _address: &Address, - ) -> Result<()> { - unimplemented!() - } - - fn inc_nonce( - &mut self, _address: &Address, _account_start_nonce: &U256, - ) -> Result<()> { - unimplemented!() - } - - fn set_nonce(&mut self, _address: &Address, _nonce: &U256) -> Result<()> { - unimplemented!() - } - - fn sub_balance( - &mut self, address: &Address, by: &U256, cleanup_mode: &mut CleanupMode, - ) -> Result<()> { - if !by.is_zero() { - self.modify_and_update_account(address, None)? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(*address).into()), - |value| { - value.balance = value.balance - *by; - Ok(()) - }, - )?; - } - if let CleanupMode::TrackTouched(ref mut set) = *cleanup_mode { - if self.exists(address)? { - set.insert(*address); - } - } - Ok(()) - } - - fn add_balance( - &mut self, _address: &Address, _by: &U256, _cleanup_mode: CleanupMode, - _account_start_nonce: U256, - ) -> Result<()> - { - unimplemented!() - } - - fn add_pos_interest( - &mut self, _address: &Address, _by: &U256, _cleanup_mode: CleanupMode, - _account_start_nonce: U256, - ) -> Result<()> - { - unimplemented!() - } - - fn transfer_balance( - &mut self, _from: &Address, _to: &Address, _by: &U256, - _cleanup_mode: CleanupMode, _account_start_nonce: U256, - ) -> Result<()> - { - unimplemented!() - } - - fn deposit( - &mut self, _address: &Address, _amount: &U256, - _current_block_number: u64, - ) -> Result<()> - { - unimplemented!() - } - - fn withdraw(&mut self, _address: &Address, _amount: &U256) -> Result { - unimplemented!() - } - - fn vote_lock( - &mut self, address: &Address, amount: &U256, unlock_block_number: u64, - ) -> Result<()> { - let staking_balance = self.staking_balance(address)?; - if *amount > staking_balance { - return Ok(()); - } - self.modify_and_update_vote_stake_list(address, None)? - .as_mut() - .map_or_else( - || unreachable!(), - |vote_stake_list| { - vote_stake_list.vote_lock(*amount, unlock_block_number); - Ok(()) - }, - ) - } - - fn remove_expired_vote_stake_info( - &mut self, address: &Address, current_block_number: u64, - ) -> Result<()> { - self.modify_and_update_vote_stake_list(address, None)? - .as_mut() - .map_or_else( - || unreachable!(), - |vote_stake_list| { - vote_stake_list - .remove_expired_vote_stake_info(current_block_number); - Ok(()) - }, - ) - } - - fn total_issued_tokens(&self) -> U256 { - return self - .storage_at( - &STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS, - TOTAL_TOKENS_KEY, - ) - .unwrap_or(U256::zero()); - } - - fn total_staking_tokens(&self) -> U256 { - return self - .storage_at( - &STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS, - TOTAL_BANK_TOKENS_KEY, - ) - .unwrap_or(U256::zero()); - } - - fn total_storage_tokens(&self) -> U256 { - return self - .storage_at( - &STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS, - TOTAL_STORAGE_TOKENS_KEY, - ) - .unwrap_or(U256::zero()); - } - - fn total_pos_staking_tokens(&self) -> U256 { unimplemented!() } - - fn distributable_pos_interest(&self) -> U256 { unimplemented!() } - - fn last_distribute_block(&self) -> u64 { unimplemented!() } - - fn remove_contract(&mut self, _address: &Address) -> Result<()> { - unimplemented!() - } - - fn exists(&self, address: &Address) -> Result { - Ok(self.get_account(address)?.as_ref().is_none()) - } - - fn exists_and_not_null(&self, address: &Address) -> Result { - Ok(self.get_account(address)?.as_ref().map_or(false, |a| { - a.staking_balance.is_zero() - && a.collateral_for_storage.is_zero() - && a.nonce.is_zero() - && a.code_hash == KECCAK_EMPTY - })) - } - - fn storage_at(&self, address: &Address, key: &[u8]) -> Result { - Ok(self - .get_storage(address, key)? - .as_ref() - .map_or(U256::zero(), |a| a.value)) - } - - fn set_storage( - &mut self, address: &Address, key: Vec, value: U256, owner: Address, - ) -> Result<()> { - self.modify_and_update_storage(address, &*key, None)? - .as_mut() - .map_or_else( - || unreachable!(), - |entry| { - entry.value = value; - if owner == *address { - entry.owner = None - } else { - entry.owner = Some(owner) - } - Ok(()) - }, - ) - } - - fn update_pos_status( - &mut self, _identifier: H256, _number: u64, - ) -> Result<()> { - unimplemented!() - } - - fn pos_locked_staking(&self, _address: &Address) -> Result { - unimplemented!() - } -} - -impl - State -{ - fn get_account( - &self, address: &Address, - ) -> Result>>> { - self.cache.get_account(address, &self.db) - } - - fn get_code( - &self, address: &Address, - ) -> Result>>> { - self.cache.get_code(address, &self.db) - } - - fn get_deposit_list( - &self, address: &Address, - ) -> Result>>> { - self.cache.get_deposit_list(address, &self.db) - } - - fn get_vote_stake_list( - &self, address: &Address, - ) -> Result>>> { - self.cache.get_vote_stake_list(address, &self.db) - } - - fn get_commission_privilege( - &self, contract_address: &Address, user_address: &Address, - ) -> Result>>> { - self.cache.get_commission_privilege( - contract_address, - user_address, - &self.db, - ) - } - - fn modify_and_update_commission_privilege<'a>( - &'a mut self, contract_address: &Address, user_address: &Address, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - impl AsMut< - ModifyAndUpdate< - StateDbGeneric, - /* TODO: Key, */ CachedCommissionPrivilege, - >, - >, - > - { - self.cache.modify_and_update_commission_privilege( - contract_address, - user_address, - &mut self.db, - debug_record, - ) - } - - fn get_storage( - &self, address: &Address, key: &[u8], - ) -> Result>>> { - self.cache.get_storage(address, key, &self.db) - } - - fn modify_and_update_account<'a>( - &'a mut self, address: &Address, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - impl AsMut, CachedAccount>>, - > - { - self.cache.modify_and_update_account( - address, - &mut self.db, - debug_record, - ) - } - - fn modify_and_update_vote_stake_list<'a>( - &'a mut self, address: &Address, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - impl AsMut, VoteStakeList>>, - > - { - self.cache.modify_and_update_vote_stake_list( - address, - &mut self.db, - debug_record, - ) - } - - fn modify_and_update_storage<'a>( - &'a mut self, address: &Address, key: &[u8], - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - impl AsMut, StorageValue>>, - > - { - self.cache.modify_and_update_storage( - address, - key, - &mut self.db, - debug_record, - ) - } - - fn write_account_or_new<'a>( - &'a mut self, address: &Address, account_start_nonce: &U256, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - impl AsMut, CachedAccount>>, - > - { - self.cache.write_account_or_new( - address, - &mut self.db, - account_start_nonce, - debug_record, - ) - } - - fn require_or_set_code<'a>( - &'a mut self, address: Address, code_owner: Address, code: Vec, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result<()> - { - self.cache.require_or_set_code( - address, - code_owner, - code, - &mut self.db, - debug_record, - ) - } -} - -use crate::{ - cache_object::{CachedAccount, CachedCommissionPrivilege}, - maybe_address, - state_object_cache::{ModifyAndUpdate, StateObjectCache}, - state_trait::{CheckpointTrait, StateOpsTrait}, - substate_trait::SubstateMngTrait, - CleanupMode, CollateralCheckResult, StateTrait, -}; -use cfx_internal_common::{ - debug::ComputeEpochDebugRecord, StateRootWithAuxInfo, -}; -use cfx_parameters::internal_contract_addresses::STORAGE_INTEREST_STAKING_CONTRACT_ADDRESS; -use cfx_statedb::{ - ErrorKind, Result, StateDbCheckpointMethods, StateDbGeneric, - TOTAL_BANK_TOKENS_KEY, TOTAL_STORAGE_TOKENS_KEY, TOTAL_TOKENS_KEY, -}; -use cfx_storage::{utils::guarded_value::NonCopy, StorageStateTrait}; -use cfx_types::{Address, H256}; -use keccak_hash::{keccak, KECCAK_EMPTY}; -use primitives::{ - CodeInfo, DepositList, EpochId, SponsorInfo, StorageLayout, StorageValue, - VoteStakeList, -}; -use std::{marker::PhantomData, ops::Deref, sync::Arc}; diff --git a/core/state/src/state_object_cache.rs b/core/state/src/state_object_cache.rs deleted file mode 100644 index 5c2cfc8a25..0000000000 --- a/core/state/src/state_object_cache.rs +++ /dev/null @@ -1,497 +0,0 @@ -// Copyright 2021 Conflux Foundation. All rights reserved. -// Conflux is free software and distributed under GNU General Public License. -// See http://www.gnu.org/licenses/ - -#[allow(unused)] -pub struct StateObjectCache { - // TODO: at this moment this is fixed to 0 (no cache size limit). - // To limit the cache size we must remember to obtain the list of - // all updated account for the transaction pool. - max_cache_size: usize, - account_cache: RwLock>>, - code_cache: RwLock>>, - deposit_list_cache: - RwLock>>, - vote_stake_list_cache: - RwLock>>, - commission_privilege_cache: RwLock< - HashMap>, - >, - storage_cache: RwLock>>, - // TODO: etc. -} - -pub struct ModifyAndUpdate<'a, StateDb: StateDbOps, T: CachedObject> { - db: &'a mut StateDb, - key: T::HashKeyType, - value: &'a mut Option, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, -} - -impl<'a, StateDb: StateDbOps, T: CachedObject> ModifyAndUpdate<'a, StateDb, T> { - // Note: if a value exists, the ModifyAndUpdate object will be "finalized" - // before exit. - pub fn map_or_else< - D: FnOnce() -> Result, - F: FnOnce(&mut T) -> Result, - U, - >( - &mut self, default: D, f: F, - ) -> Result { - match self.value { - None => default(), - Some(value) => { - let result = f(value); - self.finalize()?; - result - } - } - } - - pub fn finalize(&mut self) -> Result<()> { - match self.value { - None => { - T::delete(&self.key, self.db, self.debug_record.as_deref_mut())? - } - Some(value) => value.update( - &self.key, - self.db, - self.debug_record.as_deref_mut(), - )?, - } - Ok(()) - } -} - -impl<'a, StateDb: StateDbOps, T: CachedObject> Drop - for ModifyAndUpdate<'a, StateDb, T> -{ - fn drop(&mut self) { - unreachable!( - "User should always call the finalize \ - method to propogate the potential db error." - ); - } -} - -impl StateObjectCache { - pub fn clear(&mut self) { - self.account_cache.get_mut().clear(); - // TODO: etc. - } - - fn ensure_loaded< - 'c, - StateDb: StateDbOps, - Value: CachedObject, - Key: Hash + Eq + ToHashKey<::HashKeyType>, - >( - cache: &'c RwLock< - HashMap<::HashKeyType, Option>, - >, - key: &Key, db: &StateDb, - ) -> Result< - GuardedValue< - RwLockReadGuard< - 'c, - HashMap<::HashKeyType, Option>, - >, - NonCopy>, - >, - > - where - ::HashKeyType: Eq + Hash + Borrow, - { - // Return immediately when there is no need to have db operation. - { - let (read_lock, derefed) = - GuardedValue::new_derefed(cache.read()).into(); - if let Some(value) = derefed.get(key) { - return Ok(GuardedValue::new( - read_lock, - NonCopy(value.as_ref()), - )); - } - } - - // Hold an upgradable read lock while loading db for better performance. - let upgradable_read_lock = cache.upgradable_read(); - if !upgradable_read_lock.contains_key(key) { - let hash_key = Key::to_hash_key(key); - let loaded = Value::load(&hash_key, db)?; - let mut write_lock = - RwLockUpgradableReadGuard::upgrade(upgradable_read_lock); - write_lock.insert(hash_key, loaded); - - let (read_lock, derefed) = GuardedValue::new_derefed( - RwLockWriteGuard::downgrade(write_lock), - ) - .into(); - Ok(GuardedValue::new( - read_lock, - NonCopy( - derefed - .get(key) - .map_or(None, |value_optional| value_optional.as_ref()), - ), - )) - } else { - let (read_lock, derefed) = GuardedValue::new_derefed( - RwLockUpgradableReadGuard::downgrade(upgradable_read_lock), - ) - .into(); - Ok(GuardedValue::new( - read_lock, - NonCopy( - derefed - .get(key) - .map_or(None, |value_optional| value_optional.as_ref()), - ), - )) - } - } - - fn require_or_set< - 'c, - StateDb: StateDbOps, - Value: CachedObject, - Key: Hash + Eq + ToHashKey<::HashKeyType>, - F, - >( - cache: &'c RwLock< - HashMap<::HashKeyType, Option>, - >, - key: &Key, db: &'c mut StateDb, default: F, - debug_record: Option<&'c mut ComputeEpochDebugRecord>, - ) -> Result< - GuardedValue< - RwLockWriteGuard< - 'c, - HashMap<::HashKeyType, Option>, - >, - ModifyAndUpdate<'c, StateDb, Value>, - >, - > - where - ::HashKeyType: Eq + Hash + Borrow, - F: FnOnce(&Key) -> Result>, - { - let upgradable_read_lock = cache.upgradable_read(); - let mut write_lock; - if !upgradable_read_lock.contains_key(key) { - let hash_key = Key::to_hash_key(key); - let loaded = Value::load(&hash_key, db)?; - write_lock = - RwLockUpgradableReadGuard::upgrade(upgradable_read_lock); - write_lock.insert(hash_key, loaded); - } else { - write_lock = - RwLockUpgradableReadGuard::upgrade(upgradable_read_lock); - } - - let (write_lock, deref) = - GuardedValue::new_derefed_mut(write_lock).into(); - let value = deref - .get_mut(key) - .expect("entry known to exist in the cache"); - - if value.is_none() { - *value = default(key)?; - } - - Ok(GuardedValue::new( - write_lock, - ModifyAndUpdate { - db, - key: key.to_hash_key(), - value, - debug_record, - }, - )) - } - - pub fn get_account( - &self, address: &Address, db: &StateDb, - ) -> Result< - GuardedValue< - RwLockReadGuard>>, - NonCopy>, - >, - > { - Self::ensure_loaded(&self.account_cache, address, db) - } - - pub fn modify_and_update_commission_privilege<'a, StateDb: StateDbOps>( - &'a self, contract_address: &Address, user_address: &Address, - db: &'a mut StateDb, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - GuardedValue< - RwLockWriteGuard< - HashMap< - CommissionPrivilegeAddress, - Option, - >, - >, - ModifyAndUpdate< - StateDb, - /* TODO: Key, */ CachedCommissionPrivilege, - >, - >, - > - { - Self::require_or_set( - &self.commission_privilege_cache, - &CommissionPrivilegeAddress::new(*contract_address, *user_address), - db, - |_addr| Ok(Some(CachedCommissionPrivilege::new(false))), - debug_record, - ) - } - - pub fn modify_and_update_account<'a, StateDb: StateDbOps>( - &'a self, address: &Address, db: &'a mut StateDb, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - GuardedValue< - RwLockWriteGuard>>, - ModifyAndUpdate, - >, - > - { - Self::require_or_set( - &self.account_cache, - address, - db, - |_addr| Ok(None), - debug_record, - ) - } - - pub fn write_account_or_new<'a, StateDb: StateDbOps>( - &'a self, address: &Address, db: &'a mut StateDb, - account_start_nonce: &U256, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - GuardedValue< - RwLockWriteGuard>>, - ModifyAndUpdate, - >, - > - { - Self::require_or_set( - &self.account_cache, - address, - db, - |address| { - if address.is_valid_address() { - // Note that it is possible to first send money to a - // pre-calculated contract address and - // then deploy contracts. So we are going to *allow* sending - // to a contract address and use - // new_basic() to create a *stub* there. Because the - // contract serialization is a super-set - // of the normal address serialization, this should just - // work. - Ok(Some(CachedAccount::new_basic( - address, - &U256::zero(), - account_start_nonce, - ))) - } else { - unreachable!( - "address does not already exist and is not a valid address. {:?}", - address - ) - } - }, - debug_record, - ) - } - - pub fn require_or_set_code<'a, StateDb: StateDbOps>( - &'a self, address: Address, code_owner: Address, code: Vec, - db: &'a mut StateDb, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result<()> - { - Self::require_or_set( - &self.code_cache, - &CodeAddress(address, keccak(&code)), - db, - |_addr| Ok(None), - debug_record, - )? - .as_mut() - .map_or_else( - || Err(ErrorKind::IncompleteDatabase(address).into()), - |value| { - value.owner = code_owner; - value.code = Arc::new(code); - Ok(()) - }, - ) - } - - pub fn get_code( - &self, contract_address: &Address, db: &StateDb, - ) -> Result< - GuardedValue< - RwLockReadGuard>>, - NonCopy>, - >, - > { - let code_hash; - { - match self.get_account(contract_address, db)?.as_ref().as_ref() { - None => { - return Ok(GuardedValue::new( - self.code_cache.read(), - NonCopy(None), - )); - } - Some(account) => { - if KECCAK_EMPTY.eq(&account.code_hash) { - return Ok(GuardedValue::new( - self.code_cache.read(), - NonCopy(None), - )); - } else { - code_hash = account.code_hash.clone(); - } - } - } - } - Self::ensure_loaded( - &self.code_cache, - &CodeAddress(*contract_address, code_hash), - db, - ) - } - - pub fn get_deposit_list( - &self, address: &Address, db: &StateDb, - ) -> Result< - GuardedValue< - RwLockReadGuard>>, - NonCopy>, - >, - > { - Self::ensure_loaded( - &self.deposit_list_cache, - &DepositListAddress(*address), - db, - ) - } - - pub fn get_vote_stake_list( - &self, address: &Address, db: &StateDb, - ) -> Result< - GuardedValue< - RwLockReadGuard< - HashMap>, - >, - NonCopy>, - >, - > { - Self::ensure_loaded( - &self.vote_stake_list_cache, - &VoteStakeListAddress(*address), - db, - ) - } - - pub fn modify_and_update_vote_stake_list<'a, StateDb: StateDbOps>( - &'a self, address: &Address, db: &'a mut StateDb, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - GuardedValue< - RwLockWriteGuard< - HashMap>, - >, - ModifyAndUpdate, - >, - > - { - Self::require_or_set( - &self.vote_stake_list_cache, - &VoteStakeListAddress(*address), - db, - |_addr| Ok(Some(VoteStakeList(vec![]))), - debug_record, - ) - } - - pub fn get_commission_privilege( - &self, contract_address: &Address, user_address: &Address, db: &StateDb, - ) -> Result< - GuardedValue< - RwLockReadGuard< - HashMap< - CommissionPrivilegeAddress, - Option, - >, - >, - NonCopy>, - >, - > { - Self::ensure_loaded( - &self.commission_privilege_cache, - &CommissionPrivilegeAddress::new(*contract_address, *user_address), - db, - ) - } - - pub fn get_storage( - &self, address: &Address, key: &[u8], db: &StateDb, - ) -> Result< - GuardedValue< - RwLockReadGuard>>, - NonCopy>, - >, - > { - Self::ensure_loaded( - &self.storage_cache, - &StorageAddress(*address, key.to_vec()), - db, - ) - } - - pub fn modify_and_update_storage<'a, StateDb: StateDbOps>( - &'a self, address: &Address, key: &[u8], db: &'a mut StateDb, - debug_record: Option<&'a mut ComputeEpochDebugRecord>, - ) -> Result< - GuardedValue< - RwLockWriteGuard>>, - ModifyAndUpdate, - >, - > - { - Self::require_or_set( - &self.storage_cache, - &StorageAddress(*address, key.to_vec()), - db, - |_addr| Ok(Some(Default::default())), - debug_record, - ) - } -} - -use crate::{ - cache_object::{ - CachedAccount, CachedCommissionPrivilege, CachedObject, CodeAddress, - CommissionPrivilegeAddress, DepositListAddress, StorageAddress, - ToHashKey, VoteStakeListAddress, - }, - StateDbOps, -}; -use cfx_internal_common::debug::ComputeEpochDebugRecord; -use cfx_statedb::{ErrorKind, Result}; -use cfx_storage::utils::guarded_value::{GuardedValue, NonCopy}; -use cfx_types::{address_util::AddressUtil, Address, U256}; -use keccak_hash::{keccak, KECCAK_EMPTY}; -use parking_lot::{ - RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, RwLockWriteGuard, -}; -use primitives::{CodeInfo, DepositList, StorageValue, VoteStakeList}; -use std::{borrow::Borrow, collections::HashMap, hash::Hash, sync::Arc}; diff --git a/accounts/Cargo.toml b/crates/accounts/Cargo.toml similarity index 84% rename from accounts/Cargo.toml rename to crates/accounts/Cargo.toml index 7d5179d41b..484fa2e865 100644 --- a/accounts/Cargo.toml +++ b/crates/accounts/Cargo.toml @@ -8,8 +8,8 @@ authors = ["Conflux Foundation"] edition = "2018" [dependencies] -cfxkey = { path = "cfxkey" } -cfxstore = { path = "cfxstore" } +cfxkey = { path = "../cfx_key" } +cfxstore = { path = "../cfx_store" } cfx-types = { path = "../cfx_types" } log = "0.4" parking_lot = "0.11" diff --git a/accounts/src/account_data.rs b/crates/accounts/src/account_data.rs similarity index 100% rename from accounts/src/account_data.rs rename to crates/accounts/src/account_data.rs diff --git a/accounts/src/error.rs b/crates/accounts/src/error.rs similarity index 100% rename from accounts/src/error.rs rename to crates/accounts/src/error.rs diff --git a/accounts/src/lib.rs b/crates/accounts/src/lib.rs similarity index 99% rename from accounts/src/lib.rs rename to crates/accounts/src/lib.rs index 9ee88c5cbf..bfdd6d540d 100644 --- a/accounts/src/lib.rs +++ b/crates/accounts/src/lib.rs @@ -175,8 +175,7 @@ impl AccountProvider { pub fn derive_account( &self, address: &Address, password: Option, derivation: Derivation, save: bool, - ) -> Result - { + ) -> Result { let account = self.sstore.account_ref(&address)?; let password = password .map(Ok) @@ -406,8 +405,7 @@ impl AccountProvider { fn password_with_unlocked( unlocked: &mut HashMap, account: &StoreAccountRef, - ) -> Result - { + ) -> Result { let data = unlocked.get(account).ok_or(SignError::NotUnlocked)?.clone(); if let Unlock::OneTime = data.unlock { unlocked @@ -501,8 +499,7 @@ impl AccountProvider { pub fn sign_derived( &self, address: &Address, password: Option, derivation: Derivation, message: Message, - ) -> Result - { + ) -> Result { let account = self.sstore.account_ref(address)?; let password = password .map(Ok) @@ -548,8 +545,7 @@ impl AccountProvider { pub fn decrypt_with_token( &self, address: Address, token: AccountToken, shared_mac: &[u8], message: &[u8], - ) -> Result<(Vec, AccountToken), SignError> - { + ) -> Result<(Vec, AccountToken), SignError> { let account = self.sstore.account_ref(&address)?; let is_std_password = self.sstore.test_password(&account, &token)?; @@ -582,8 +578,7 @@ impl AccountProvider { pub fn decrypt( &self, address: Address, password: Option, shared_mac: &[u8], message: &[u8], - ) -> Result, SignError> - { + ) -> Result, SignError> { let account = self.sstore.account_ref(&address)?; let password = password .map(Ok) @@ -597,8 +592,7 @@ impl AccountProvider { pub fn agree( &self, address: Address, password: Option, other_public: &Public, - ) -> Result - { + ) -> Result { let account = self.sstore.account_ref(&address)?; let password = password .map(Ok) diff --git a/accounts/src/stores.rs b/crates/accounts/src/stores.rs similarity index 100% rename from accounts/src/stores.rs rename to crates/accounts/src/stores.rs diff --git a/blockgen/Cargo.toml b/crates/blockgen/Cargo.toml similarity index 73% rename from blockgen/Cargo.toml rename to crates/blockgen/Cargo.toml index c84a8688bd..dcc8811a44 100644 --- a/blockgen/Cargo.toml +++ b/crates/blockgen/Cargo.toml @@ -8,12 +8,12 @@ edition = "2018" [dependencies] clap = "2" -cfxcore = { path = "../core" } -cfxkey = { path = "../accounts/cfxkey" } -cfx-parameters = { path = "../core/parameters" } -cfx-stratum = { path = "stratum" } +cfxcore = { path = "../cfxcore/core" } +cfxkey = { path = "../cfx_key" } +cfx-parameters = { path = "../cfxcore/parameters" } +cfx-stratum = { path = "../stratum" } cfx-types = { path = "../cfx_types" } -db = { path = "../db" } +db = { path = "../dbs/db" } lazy_static = "1.4" log = "0.4" metrics = { path = "../util/metrics" } diff --git a/blockgen/src/lib.rs b/crates/blockgen/src/lib.rs similarity index 99% rename from blockgen/src/lib.rs rename to crates/blockgen/src/lib.rs index 0c4ad86198..a804d366f4 100644 --- a/blockgen/src/lib.rs +++ b/crates/blockgen/src/lib.rs @@ -75,8 +75,7 @@ impl Worker { bg: Arc, solution_sender: mpsc::Sender, problem_receiver: mpsc::Receiver, - ) -> Self - { + ) -> Self { let bg_handle = bg; let thread = thread::Builder::new() @@ -148,8 +147,7 @@ impl BlockGenerator { maybe_txgen: Option, pow_config: ProofOfWorkConfig, pow: Arc, mining_author: Address, pos_verifier: Arc, - ) -> Self - { + ) -> Self { BlockGenerator { pow_config, pow, @@ -204,8 +202,7 @@ impl BlockGenerator { mut blame_info: StateBlameInfo, block_gas_limit: U256, transactions: Vec>, difficulty: u64, adaptive_opt: Option, maybe_pos_reference: Option, - ) -> Block - { + ) -> Block { trace!("{} txs packed", transactions.len()); let consensus_graph = self.consensus_graph(); if adaptive_opt.is_none() { @@ -293,8 +290,7 @@ impl BlockGenerator { &self, parent_hash: H256, referee: Vec, num_txs: usize, difficulty: u64, adaptive: bool, block_gas_limit: u64, pos_reference: Option, - ) -> Result - { + ) -> Result { let consensus_graph = self.consensus_graph(); let state_blame_info = consensus_graph .force_compute_blame_and_deferred_state_for_generation( @@ -331,8 +327,7 @@ impl BlockGenerator { pub fn assemble_new_block( &self, num_txs: usize, block_size_limit: usize, additional_transactions: Vec>, - ) -> Block - { + ) -> Block { let consensus_graph = self.consensus_graph(); let (best_info, block_gas_limit, transactions) = @@ -394,8 +389,7 @@ impl BlockGenerator { blame_override: Option, state_root_override: Option, receipt_root_override: Option, logs_bloom_hash_override: Option, - ) -> Block - { + ) -> Block { let consensus_graph = self.consensus_graph(); let (best_info, block_gas_limit, transactions) = @@ -478,8 +472,7 @@ impl BlockGenerator { pub fn generate_fixed_block( &self, parent_hash: H256, referee: Vec, num_txs: usize, difficulty: u64, adaptive: bool, pos_reference: Option, - ) -> Result - { + ) -> Result { let block = self.assemble_new_fixed_block( parent_hash, referee, @@ -496,8 +489,7 @@ impl BlockGenerator { pub fn generate_block( &self, num_txs: usize, block_size_limit: usize, additional_transactions: Vec>, - ) -> H256 - { + ) -> H256 { let block = self.assemble_new_block( num_txs, block_size_limit, @@ -513,8 +505,7 @@ impl BlockGenerator { additional_transactions: Vec>, blame: Option, state_root: Option, receipts_root: Option, logs_bloom_hash: Option, - ) -> H256 - { + ) -> H256 { let block = self.assemble_new_block_with_blame_info( num_txs, block_size_limit, @@ -530,8 +521,7 @@ impl BlockGenerator { pub fn generate_custom_block( &self, transactions: Vec>, adaptive: Option, - ) -> H256 - { + ) -> H256 { let consensus_graph = self.consensus_graph(); // get the best block let (best_info, block_gas_limit, _) = self @@ -565,8 +555,7 @@ impl BlockGenerator { &self, parent_hash: H256, referee: Vec, transactions: Vec>, adaptive: bool, maybe_custom: Option>>, - ) -> Result - { + ) -> Result { let consensus_graph = self.consensus_graph(); let state_blame_info = consensus_graph .force_compute_blame_and_deferred_state_for_generation( @@ -594,8 +583,7 @@ impl BlockGenerator { &self, parent_hash: H256, referee: Vec, transactions: Vec>, nonce: U256, timestamp: u64, adaptive: bool, - ) -> Result - { + ) -> Result { let consensus_graph = self.consensus_graph(); let state_blame_info = consensus_graph .force_compute_blame_and_deferred_state_for_generation( diff --git a/blockgen/src/miner/mod.rs b/crates/blockgen/src/miner/mod.rs similarity index 100% rename from blockgen/src/miner/mod.rs rename to crates/blockgen/src/miner/mod.rs diff --git a/blockgen/src/miner/stratum.rs b/crates/blockgen/src/miner/stratum.rs similarity index 99% rename from blockgen/src/miner/stratum.rs rename to crates/blockgen/src/miner/stratum.rs index 1b2bea8577..c4ba98f684 100644 --- a/blockgen/src/miner/stratum.rs +++ b/crates/blockgen/src/miner/stratum.rs @@ -193,8 +193,7 @@ impl StratumJobDispatcher { fn new( solution_sender: mpsc::Sender, pow: Arc, pow_window_size: usize, - ) -> StratumJobDispatcher - { + ) -> StratumJobDispatcher { StratumJobDispatcher { recent_problems: Mutex::new(vec![]), solution_sender: Mutex::new(solution_sender), @@ -268,8 +267,7 @@ impl Stratum { pub fn start( options: &Options, pow: Arc, pow_window_size: usize, solution_sender: mpsc::Sender, - ) -> Result - { + ) -> Result { use std::net::IpAddr; let dispatcher = Arc::new(StratumJobDispatcher::new( diff --git a/blockgen/src/miner/work_notify.rs b/crates/blockgen/src/miner/work_notify.rs similarity index 100% rename from blockgen/src/miner/work_notify.rs rename to crates/blockgen/src/miner/work_notify.rs diff --git a/cfx_addr/rust/Cargo.toml b/crates/cfx_addr/Cargo.toml similarity index 80% rename from cfx_addr/rust/Cargo.toml rename to crates/cfx_addr/Cargo.toml index 7cae416279..0d09686280 100644 --- a/cfx_addr/rust/Cargo.toml +++ b/crates/cfx_addr/Cargo.toml @@ -5,6 +5,6 @@ license = "GPL-3.0" description = "Conflux Address Encoder/Decoder" [dependencies] -cfx-types = { path = "../../cfx_types" } +cfx-types = { path = "../cfx_types" } lazy_static = "1.4" rustc-hex = "2.1" diff --git a/cfx_addr/rust/src/LICENSE.rust-bitcoincash-addr b/crates/cfx_addr/src/LICENSE.rust-bitcoincash-addr similarity index 100% rename from cfx_addr/rust/src/LICENSE.rust-bitcoincash-addr rename to crates/cfx_addr/src/LICENSE.rust-bitcoincash-addr diff --git a/cfx_addr/rust/src/checksum.rs b/crates/cfx_addr/src/checksum.rs similarity index 100% rename from cfx_addr/rust/src/checksum.rs rename to crates/cfx_addr/src/checksum.rs diff --git a/cfx_addr/rust/src/consts.rs b/crates/cfx_addr/src/consts.rs similarity index 100% rename from cfx_addr/rust/src/consts.rs rename to crates/cfx_addr/src/consts.rs diff --git a/cfx_addr/rust/src/errors.rs b/crates/cfx_addr/src/errors.rs similarity index 100% rename from cfx_addr/rust/src/errors.rs rename to crates/cfx_addr/src/errors.rs diff --git a/cfx_addr/rust/src/lib.rs b/crates/cfx_addr/src/lib.rs similarity index 100% rename from cfx_addr/rust/src/lib.rs rename to crates/cfx_addr/src/lib.rs diff --git a/cfx_addr/rust/src/tests.rs b/crates/cfx_addr/src/tests.rs similarity index 100% rename from cfx_addr/rust/src/tests.rs rename to crates/cfx_addr/src/tests.rs diff --git a/cfx_bytes/Cargo.toml b/crates/cfx_bytes/Cargo.toml similarity index 100% rename from cfx_bytes/Cargo.toml rename to crates/cfx_bytes/Cargo.toml diff --git a/cfx_bytes/src/lib.rs b/crates/cfx_bytes/src/lib.rs similarity index 100% rename from cfx_bytes/src/lib.rs rename to crates/cfx_bytes/src/lib.rs diff --git a/accounts/cfxkey/Cargo.toml b/crates/cfx_key/Cargo.toml similarity index 53% rename from accounts/cfxkey/Cargo.toml rename to crates/cfx_key/Cargo.toml index b9f3c70363..604b3d75f1 100644 --- a/accounts/cfxkey/Cargo.toml +++ b/crates/cfx_key/Cargo.toml @@ -5,7 +5,7 @@ version = "0.3.0" authors = ["Conflux Foundation"] [dependencies] -cfx-types = { path = "../../cfx_types" } +cfx-types = { path = "../cfx_types" } edit-distance = "2.0" parity-crypto = "0.9.0" parity-secp256k1 = "0.7.0" @@ -19,5 +19,10 @@ serde = "1.0" serde_derive = "1.0" tiny-keccak = "1.4" zeroize = "1.0.0" -malloc_size_of_derive = {path = "../../util/malloc_size_of_derive"} -malloc_size_of = {path = "../../util/malloc_size_of"} +malloc_size_of_derive = {path = "../util/malloc_size_of_derive" } +malloc_size_of = {path = "../util/malloc_size_of" } +docopt = "1.0" +env_logger = "0.5" +panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } +threadpool = "1.7" + diff --git a/accounts/cfxkey/README.md b/crates/cfx_key/README.md similarity index 100% rename from accounts/cfxkey/README.md rename to crates/cfx_key/README.md diff --git a/accounts/cfxkey/src/brain.rs b/crates/cfx_key/src/brain.rs similarity index 100% rename from accounts/cfxkey/src/brain.rs rename to crates/cfx_key/src/brain.rs diff --git a/accounts/cfxkey/src/brain_prefix.rs b/crates/cfx_key/src/brain_prefix.rs similarity index 100% rename from accounts/cfxkey/src/brain_prefix.rs rename to crates/cfx_key/src/brain_prefix.rs diff --git a/accounts/cfxkey/src/brain_recover.rs b/crates/cfx_key/src/brain_recover.rs similarity index 100% rename from accounts/cfxkey/src/brain_recover.rs rename to crates/cfx_key/src/brain_recover.rs diff --git a/accounts/cfxkey/src/crypto.rs b/crates/cfx_key/src/crypto.rs similarity index 100% rename from accounts/cfxkey/src/crypto.rs rename to crates/cfx_key/src/crypto.rs diff --git a/accounts/cfxkey/src/error.rs b/crates/cfx_key/src/error.rs similarity index 100% rename from accounts/cfxkey/src/error.rs rename to crates/cfx_key/src/error.rs diff --git a/accounts/cfxkey/src/extended.rs b/crates/cfx_key/src/extended.rs similarity index 100% rename from accounts/cfxkey/src/extended.rs rename to crates/cfx_key/src/extended.rs diff --git a/accounts/cfxkey/src/keccak.rs b/crates/cfx_key/src/keccak.rs similarity index 100% rename from accounts/cfxkey/src/keccak.rs rename to crates/cfx_key/src/keccak.rs diff --git a/accounts/cfxkey/src/keypair.rs b/crates/cfx_key/src/keypair.rs similarity index 100% rename from accounts/cfxkey/src/keypair.rs rename to crates/cfx_key/src/keypair.rs diff --git a/accounts/cfxkey/src/lib.rs b/crates/cfx_key/src/lib.rs similarity index 100% rename from accounts/cfxkey/src/lib.rs rename to crates/cfx_key/src/lib.rs diff --git a/accounts/cfxkey/src/math.rs b/crates/cfx_key/src/math.rs similarity index 100% rename from accounts/cfxkey/src/math.rs rename to crates/cfx_key/src/math.rs diff --git a/accounts/cfxkey/src/password.rs b/crates/cfx_key/src/password.rs similarity index 100% rename from accounts/cfxkey/src/password.rs rename to crates/cfx_key/src/password.rs diff --git a/accounts/cfxkey/src/prefix.rs b/crates/cfx_key/src/prefix.rs similarity index 100% rename from accounts/cfxkey/src/prefix.rs rename to crates/cfx_key/src/prefix.rs diff --git a/accounts/cfxkey/src/random.rs b/crates/cfx_key/src/random.rs similarity index 100% rename from accounts/cfxkey/src/random.rs rename to crates/cfx_key/src/random.rs diff --git a/accounts/cfxkey/src/secret.rs b/crates/cfx_key/src/secret.rs similarity index 100% rename from accounts/cfxkey/src/secret.rs rename to crates/cfx_key/src/secret.rs diff --git a/accounts/cfxkey/src/signature.rs b/crates/cfx_key/src/signature.rs similarity index 100% rename from accounts/cfxkey/src/signature.rs rename to crates/cfx_key/src/signature.rs diff --git a/cfx_math/Cargo.toml b/crates/cfx_math/Cargo.toml similarity index 100% rename from cfx_math/Cargo.toml rename to crates/cfx_math/Cargo.toml diff --git a/cfx_math/benches/basic.rs b/crates/cfx_math/benches/basic.rs similarity index 100% rename from cfx_math/benches/basic.rs rename to crates/cfx_math/benches/basic.rs diff --git a/cfx_math/benches/bench.rs b/crates/cfx_math/benches/bench.rs similarity index 100% rename from cfx_math/benches/bench.rs rename to crates/cfx_math/benches/bench.rs diff --git a/cfx_math/src/lib.rs b/crates/cfx_math/src/lib.rs similarity index 79% rename from cfx_math/src/lib.rs rename to crates/cfx_math/src/lib.rs index 19f5385d41..c2464cc066 100644 --- a/cfx_math/src/lib.rs +++ b/crates/cfx_math/src/lib.rs @@ -19,10 +19,9 @@ pub fn sqrt_u256(input: U256) -> U256 { } /************************************************************ - ** Step 1: pick the most significant 64 bits and estimate an - ** approximate root. - ************************************************************ - **/ + * Step 1: pick the most significant 64 bits and estimate an + * approximate root. + ===========================================================*/ let significant_bits = 64 - bits % 2; // The `rest_bits` must be even number. let rest_bits = bits - significant_bits; @@ -32,10 +31,9 @@ pub fn sqrt_u256(input: U256) -> U256 { let init_root = U256::from(significant_word.sqrt() + 1u64) << (rest_bits / 2); - /****************************************************************** - ** Step 2: use the Newton's method to estimate the accurate value. - ****************************************************************** - **/ + /*================================================================= + * Step 2: use the Newton's method to estimate the accurate value. + =================================================================*/ let mut root = init_root; // Will iterate for at most 4 rounds. while root * root > input { diff --git a/cfx_math/src/nth_root/compute.rs b/crates/cfx_math/src/nth_root/compute.rs similarity index 100% rename from cfx_math/src/nth_root/compute.rs rename to crates/cfx_math/src/nth_root/compute.rs diff --git a/cfx_math/src/nth_root/const_generic.rs b/crates/cfx_math/src/nth_root/const_generic.rs similarity index 100% rename from cfx_math/src/nth_root/const_generic.rs rename to crates/cfx_math/src/nth_root/const_generic.rs diff --git a/cfx_math/src/nth_root/inv.rs b/crates/cfx_math/src/nth_root/inv.rs similarity index 100% rename from cfx_math/src/nth_root/inv.rs rename to crates/cfx_math/src/nth_root/inv.rs diff --git a/cfx_math/src/nth_root/mod.rs b/crates/cfx_math/src/nth_root/mod.rs similarity index 100% rename from cfx_math/src/nth_root/mod.rs rename to crates/cfx_math/src/nth_root/mod.rs diff --git a/cfx_math/src/nth_root/root_degree/exponential_table.rs b/crates/cfx_math/src/nth_root/root_degree/exponential_table.rs similarity index 100% rename from cfx_math/src/nth_root/root_degree/exponential_table.rs rename to crates/cfx_math/src/nth_root/root_degree/exponential_table.rs diff --git a/cfx_math/src/nth_root/root_degree/logarithmic_table.rs b/crates/cfx_math/src/nth_root/root_degree/logarithmic_table.rs similarity index 100% rename from cfx_math/src/nth_root/root_degree/logarithmic_table.rs rename to crates/cfx_math/src/nth_root/root_degree/logarithmic_table.rs diff --git a/cfx_math/src/nth_root/root_degree/mod.rs b/crates/cfx_math/src/nth_root/root_degree/mod.rs similarity index 100% rename from cfx_math/src/nth_root/root_degree/mod.rs rename to crates/cfx_math/src/nth_root/root_degree/mod.rs diff --git a/cfx_math/src/nth_root/tests/compile_time_check.rs b/crates/cfx_math/src/nth_root/tests/compile_time_check.rs similarity index 100% rename from cfx_math/src/nth_root/tests/compile_time_check.rs rename to crates/cfx_math/src/nth_root/tests/compile_time_check.rs diff --git a/cfx_math/src/nth_root/tests/inv.rs b/crates/cfx_math/src/nth_root/tests/inv.rs similarity index 100% rename from cfx_math/src/nth_root/tests/inv.rs rename to crates/cfx_math/src/nth_root/tests/inv.rs diff --git a/cfx_math/src/nth_root/tests/lookup_table.rs b/crates/cfx_math/src/nth_root/tests/lookup_table.rs similarity index 100% rename from cfx_math/src/nth_root/tests/lookup_table.rs rename to crates/cfx_math/src/nth_root/tests/lookup_table.rs diff --git a/cfx_math/src/nth_root/tests/mod.rs b/crates/cfx_math/src/nth_root/tests/mod.rs similarity index 100% rename from cfx_math/src/nth_root/tests/mod.rs rename to crates/cfx_math/src/nth_root/tests/mod.rs diff --git a/cfx_math/src/nth_root/tests/nth_root.rs b/crates/cfx_math/src/nth_root/tests/nth_root.rs similarity index 100% rename from cfx_math/src/nth_root/tests/nth_root.rs rename to crates/cfx_math/src/nth_root/tests/nth_root.rs diff --git a/accounts/cfxstore/Cargo.toml b/crates/cfx_store/Cargo.toml similarity index 80% rename from accounts/cfxstore/Cargo.toml rename to crates/cfx_store/Cargo.toml index a2e7a351d2..91ebc6df9e 100644 --- a/accounts/cfxstore/Cargo.toml +++ b/crates/cfx_store/Cargo.toml @@ -8,8 +8,8 @@ authors = ["Parity Technologies "] log = "0.4" libc = "0.2" rand = "0.7" -cfx-types = { path = "../../cfx_types" } -cfxkey = { path = "../cfxkey" } +cfx-types = { path = "../cfx_types" } +cfxkey = { path = "../cfx_key" } serde = "1.0" serde_json = "1.0" serde_derive = "1.0" @@ -17,7 +17,7 @@ rustc-hex = "2.1" tiny-keccak = "1.4" time = "0.1.34" parking_lot = "0.11" -parity-crypto = "0.9.0" +parity-crypto = { version = "0.9.0", features = ["publickey"] } dir = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } smallvec = "1.4" parity-wordlist = "1.0" @@ -25,5 +25,3 @@ tempdir = "0.3" [dev-dependencies] matches = "0.1" - -[lib] diff --git a/accounts/cfxstore/README.md b/crates/cfx_store/README.md similarity index 100% rename from accounts/cfxstore/README.md rename to crates/cfx_store/README.md diff --git a/accounts/cfxstore/src/account/cipher.rs b/crates/cfx_store/src/account/cipher.rs similarity index 100% rename from accounts/cfxstore/src/account/cipher.rs rename to crates/cfx_store/src/account/cipher.rs diff --git a/accounts/cfxstore/src/account/crypto.rs b/crates/cfx_store/src/account/crypto.rs similarity index 100% rename from accounts/cfxstore/src/account/crypto.rs rename to crates/cfx_store/src/account/crypto.rs diff --git a/accounts/cfxstore/src/account/kdf.rs b/crates/cfx_store/src/account/kdf.rs similarity index 100% rename from accounts/cfxstore/src/account/kdf.rs rename to crates/cfx_store/src/account/kdf.rs diff --git a/accounts/cfxstore/src/account/mod.rs b/crates/cfx_store/src/account/mod.rs similarity index 100% rename from accounts/cfxstore/src/account/mod.rs rename to crates/cfx_store/src/account/mod.rs diff --git a/accounts/cfxstore/src/account/safe_account.rs b/crates/cfx_store/src/account/safe_account.rs similarity index 98% rename from accounts/cfxstore/src/account/safe_account.rs rename to crates/cfx_store/src/account/safe_account.rs index 03cf435df6..5e3b67dfd6 100644 --- a/accounts/cfxstore/src/account/safe_account.rs +++ b/crates/cfx_store/src/account/safe_account.rs @@ -66,8 +66,7 @@ impl SafeAccount { pub fn create( keypair: &KeyPair, id: [u8; 16], password: &Password, iterations: u32, name: String, meta: String, - ) -> Result - { + ) -> Result { Ok(SafeAccount { id, version: Version::V3, @@ -93,8 +92,7 @@ impl SafeAccount { pub fn from_file( json: json::KeyFile, filename: Option, password: &Option, - ) -> Result - { + ) -> Result { let crypto = Crypto::from(json.crypto); let address = match (password, &json.address) { (None, Some(json_address)) => json_address.into(), @@ -221,8 +219,7 @@ impl SafeAccount { pub fn change_password( &self, old_password: &Password, new_password: &Password, iterations: u32, - ) -> Result - { + ) -> Result { let secret = self.crypto.secret(old_password)?; let result = SafeAccount { id: self.id.clone(), diff --git a/accounts/cfxstore/src/account/version.rs b/crates/cfx_store/src/account/version.rs similarity index 100% rename from accounts/cfxstore/src/account/version.rs rename to crates/cfx_store/src/account/version.rs diff --git a/accounts/cfxstore/src/accounts_dir/disk.rs b/crates/cfx_store/src/accounts_dir/disk.rs similarity index 100% rename from accounts/cfxstore/src/accounts_dir/disk.rs rename to crates/cfx_store/src/accounts_dir/disk.rs diff --git a/accounts/cfxstore/src/accounts_dir/memory.rs b/crates/cfx_store/src/accounts_dir/memory.rs similarity index 100% rename from accounts/cfxstore/src/accounts_dir/memory.rs rename to crates/cfx_store/src/accounts_dir/memory.rs diff --git a/accounts/cfxstore/src/accounts_dir/mod.rs b/crates/cfx_store/src/accounts_dir/mod.rs similarity index 100% rename from accounts/cfxstore/src/accounts_dir/mod.rs rename to crates/cfx_store/src/accounts_dir/mod.rs diff --git a/accounts/cfxstore/src/accounts_dir/vault.rs b/crates/cfx_store/src/accounts_dir/vault.rs similarity index 100% rename from accounts/cfxstore/src/accounts_dir/vault.rs rename to crates/cfx_store/src/accounts_dir/vault.rs diff --git a/accounts/cfxstore/src/cfxkey.rs b/crates/cfx_store/src/cfxkey.rs similarity index 100% rename from accounts/cfxstore/src/cfxkey.rs rename to crates/cfx_store/src/cfxkey.rs diff --git a/accounts/cfxstore/src/cfxstore.rs b/crates/cfx_store/src/cfxstore.rs similarity index 98% rename from accounts/cfxstore/src/cfxstore.rs rename to crates/cfx_store/src/cfxstore.rs index 22e7964ded..ec415f197d 100644 --- a/accounts/cfxstore/src/cfxstore.rs +++ b/crates/cfx_store/src/cfxstore.rs @@ -89,8 +89,7 @@ impl SimpleSecretStore for CfxStore { fn insert_derived( &self, vault: SecretVaultRef, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation, - ) -> Result - { + ) -> Result { self.store .insert_derived(vault, account_ref, password, derivation) } @@ -98,8 +97,7 @@ impl SimpleSecretStore for CfxStore { fn generate_derived( &self, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation, - ) -> Result - { + ) -> Result { self.store .generate_derived(account_ref, password, derivation) } @@ -115,8 +113,7 @@ impl SimpleSecretStore for CfxStore { fn change_password( &self, account: &StoreAccountRef, old_password: &Password, new_password: &Password, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { self.store .change_password(account, old_password, new_password) } @@ -136,16 +133,14 @@ impl SimpleSecretStore for CfxStore { fn sign( &self, account: &StoreAccountRef, password: &Password, message: &Message, - ) -> Result - { + ) -> Result { self.get(account)?.sign(password, message) } fn sign_derived( &self, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation, message: &Message, - ) -> Result - { + ) -> Result { self.store .sign_derived(account_ref, password, derivation, message) } @@ -159,8 +154,7 @@ impl SimpleSecretStore for CfxStore { fn decrypt( &self, account: &StoreAccountRef, password: &Password, shared_mac: &[u8], message: &[u8], - ) -> Result, Error> - { + ) -> Result, Error> { let account = self.get(account)?; account.decrypt(password, shared_mac, message) } @@ -218,8 +212,7 @@ impl SecretStore for CfxStore { fn import_wallet( &self, vault: SecretVaultRef, json: &[u8], password: &Password, gen_id: bool, - ) -> Result - { + ) -> Result { let json_keyfile = json::KeyFile::load(json).map_err(|_| { Error::InvalidKeyFile("Invalid JSON format".to_owned()) })?; @@ -249,8 +242,7 @@ impl SecretStore for CfxStore { &self, new_store: &dyn SimpleSecretStore, new_vault: SecretVaultRef, account: &StoreAccountRef, password: &Password, new_password: &Password, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { let account = self.get(account)?; let secret = account.crypto.secret(password)?; new_store.insert_account(new_vault, secret, new_password)?; @@ -500,8 +492,7 @@ impl CfxMultiStore { fn update( &self, account_ref: &StoreAccountRef, old: SafeAccount, new: SafeAccount, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { // save to file let account = match account_ref.vault { SecretVaultRef::Root => self.dir.update(new)?, @@ -608,8 +599,7 @@ impl SimpleSecretStore for CfxMultiStore { fn insert_derived( &self, vault: SecretVaultRef, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation, - ) -> Result - { + ) -> Result { let accounts = self.get_matching(account_ref, password)?; if let Some(account) = accounts.first() { let extended = @@ -627,8 +617,7 @@ impl SimpleSecretStore for CfxMultiStore { fn generate_derived( &self, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation, - ) -> Result - { + ) -> Result { let accounts = self.get_matching(&account_ref, password)?; if let Some(account) = accounts.first() { let extended = @@ -642,8 +631,7 @@ impl SimpleSecretStore for CfxMultiStore { fn sign_derived( &self, account_ref: &StoreAccountRef, password: &Password, derivation: Derivation, message: &Message, - ) -> Result - { + ) -> Result { let accounts = self.get_matching(&account_ref, password)?; if let Some(account) = accounts.first() { let extended = @@ -693,8 +681,7 @@ impl SimpleSecretStore for CfxMultiStore { fn change_password( &self, account_ref: &StoreAccountRef, old_password: &Password, new_password: &Password, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { let accounts = self.get_matching(account_ref, old_password)?; if accounts.is_empty() { @@ -727,8 +714,7 @@ impl SimpleSecretStore for CfxMultiStore { fn sign( &self, account: &StoreAccountRef, password: &Password, message: &Message, - ) -> Result - { + ) -> Result { let accounts = self.get_matching(account, password)?; match accounts.first() { Some(ref account) => account.sign(password, message), @@ -739,8 +725,7 @@ impl SimpleSecretStore for CfxMultiStore { fn decrypt( &self, account: &StoreAccountRef, password: &Password, shared_mac: &[u8], message: &[u8], - ) -> Result, Error> - { + ) -> Result, Error> { let accounts = self.get_matching(account, password)?; match accounts.first() { Some(ref account) => account.decrypt(password, shared_mac, message), diff --git a/accounts/cfxstore/src/error.rs b/crates/cfx_store/src/error.rs similarity index 94% rename from accounts/cfxstore/src/error.rs rename to crates/cfx_store/src/error.rs index 8dc81abaf3..ef4384afd0 100644 --- a/accounts/cfxstore/src/error.rs +++ b/crates/cfx_store/src/error.rs @@ -15,7 +15,9 @@ // along with Parity Ethereum. If not, see . use cfxkey::{self, DerivationError, Error as EthKeyError}; -use crypto::{self, Error as EthCryptoError}; +use crypto::{ + self, publickey::Error as CryptoPublicKeyError, Error as EthCryptoError, +}; use std::{fmt, io::Error as IoError}; /// Account-related errors. @@ -120,3 +122,7 @@ impl From for Error { impl From for Error { fn from(err: DerivationError) -> Self { Error::Derivation(err) } } + +impl From for Error { + fn from(err: CryptoPublicKeyError) -> Self { Error::Custom(err.into()) } +} diff --git a/accounts/cfxstore/src/import.rs b/crates/cfx_store/src/import.rs similarity index 100% rename from accounts/cfxstore/src/import.rs rename to crates/cfx_store/src/import.rs diff --git a/accounts/cfxstore/src/json/bytes.rs b/crates/cfx_store/src/json/bytes.rs similarity index 100% rename from accounts/cfxstore/src/json/bytes.rs rename to crates/cfx_store/src/json/bytes.rs diff --git a/accounts/cfxstore/src/json/cipher.rs b/crates/cfx_store/src/json/cipher.rs similarity index 100% rename from accounts/cfxstore/src/json/cipher.rs rename to crates/cfx_store/src/json/cipher.rs diff --git a/accounts/cfxstore/src/json/crypto.rs b/crates/cfx_store/src/json/crypto.rs similarity index 100% rename from accounts/cfxstore/src/json/crypto.rs rename to crates/cfx_store/src/json/crypto.rs diff --git a/accounts/cfxstore/src/json/error.rs b/crates/cfx_store/src/json/error.rs similarity index 100% rename from accounts/cfxstore/src/json/error.rs rename to crates/cfx_store/src/json/error.rs diff --git a/accounts/cfxstore/src/json/hash.rs b/crates/cfx_store/src/json/hash.rs similarity index 100% rename from accounts/cfxstore/src/json/hash.rs rename to crates/cfx_store/src/json/hash.rs diff --git a/accounts/cfxstore/src/json/id.rs b/crates/cfx_store/src/json/id.rs similarity index 100% rename from accounts/cfxstore/src/json/id.rs rename to crates/cfx_store/src/json/id.rs diff --git a/accounts/cfxstore/src/json/kdf.rs b/crates/cfx_store/src/json/kdf.rs similarity index 100% rename from accounts/cfxstore/src/json/kdf.rs rename to crates/cfx_store/src/json/kdf.rs diff --git a/accounts/cfxstore/src/json/key_file.rs b/crates/cfx_store/src/json/key_file.rs similarity index 100% rename from accounts/cfxstore/src/json/key_file.rs rename to crates/cfx_store/src/json/key_file.rs diff --git a/accounts/cfxstore/src/json/mod.rs b/crates/cfx_store/src/json/mod.rs similarity index 97% rename from accounts/cfxstore/src/json/mod.rs rename to crates/cfx_store/src/json/mod.rs index db11b945d3..6e811bb204 100644 --- a/accounts/cfxstore/src/json/mod.rs +++ b/crates/cfx_store/src/json/mod.rs @@ -24,6 +24,7 @@ mod hash; mod id; mod kdf; mod key_file; +mod presale; mod vault_file; mod vault_key_file; mod version; @@ -37,6 +38,7 @@ pub use self::{ id::Uuid, kdf::{Kdf, KdfSer, KdfSerParams, Pbkdf2, Prf, Scrypt}, key_file::{KeyFile, OpaqueKeyFile}, + presale::PresaleWallet, vault_file::VaultFile, vault_key_file::{ insert_vault_name_to_json_meta, remove_vault_name_from_json_meta, diff --git a/crates/cfx_store/src/json/presale.rs b/crates/cfx_store/src/json/presale.rs new file mode 100644 index 0000000000..71490ee0d1 --- /dev/null +++ b/crates/cfx_store/src/json/presale.rs @@ -0,0 +1,81 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of OpenEthereum. + +// OpenEthereum 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. + +// OpenEthereum 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 OpenEthereum. If not, see . + +use super::{Bytes, H160}; +use serde_json; +use std::io::Read; + +pub type Encseed = Bytes; + +#[derive(Debug, PartialEq, Deserialize)] +pub struct PresaleWallet { + pub encseed: Encseed, + #[serde(rename = "ethaddr")] + pub address: H160, +} + +impl PresaleWallet { + pub fn load(reader: R) -> Result + where R: Read { + serde_json::from_reader(reader) + } +} + +#[cfg(test)] +mod tests { + use json::{PresaleWallet, H160}; + use serde_json; + use std::str::FromStr; + + #[test] + fn presale_wallet() { + let json = r#" + { + "encseed": "137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066", + "ethaddr": "ede84640d1a1d3e06902048e67aa7db8d52c2ce1", + "email": "123@gmail.com", + "btcaddr": "1JvqEc6WLhg6GnyrLBe2ztPAU28KRfuseH" + } "#; + + let expected = PresaleWallet { + encseed: "137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066".into(), + address: H160::from_str("ede84640d1a1d3e06902048e67aa7db8d52c2ce1").unwrap(), + }; + + let wallet: PresaleWallet = serde_json::from_str(json).unwrap(); + assert_eq!(expected, wallet); + } + + #[test] + fn long_presale_wallet() { + let json = r#" + { + "encseed": + "137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0d", + "ethaddr": "ede84640d1a1d3e06902048e67aa7db8d52c2ce1", + "email": "123@gmail.com", + "btcaddr": "1JvqEc6WLhg6GnyrLBe2ztPAU28KRfuseH" + } "#; + + let expected = PresaleWallet { + encseed: "137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0dcf0d".into(), + address: H160::from_str("ede84640d1a1d3e06902048e67aa7db8d52c2ce1").unwrap(), + }; + + let wallet: PresaleWallet = serde_json::from_str(json).unwrap(); + assert_eq!(expected, wallet); + } +} diff --git a/accounts/cfxstore/src/json/vault_file.rs b/crates/cfx_store/src/json/vault_file.rs similarity index 100% rename from accounts/cfxstore/src/json/vault_file.rs rename to crates/cfx_store/src/json/vault_file.rs diff --git a/accounts/cfxstore/src/json/vault_key_file.rs b/crates/cfx_store/src/json/vault_key_file.rs similarity index 100% rename from accounts/cfxstore/src/json/vault_key_file.rs rename to crates/cfx_store/src/json/vault_key_file.rs diff --git a/accounts/cfxstore/src/json/version.rs b/crates/cfx_store/src/json/version.rs similarity index 100% rename from accounts/cfxstore/src/json/version.rs rename to crates/cfx_store/src/json/version.rs diff --git a/accounts/cfxstore/src/lib.rs b/crates/cfx_store/src/lib.rs similarity index 97% rename from accounts/cfxstore/src/lib.rs rename to crates/cfx_store/src/lib.rs index 0be155f931..38ee2f007b 100644 --- a/accounts/cfxstore/src/lib.rs +++ b/crates/cfx_store/src/lib.rs @@ -49,6 +49,7 @@ mod cfxstore; mod error; mod import; mod json; +mod presale; mod random; mod secret_store; @@ -59,6 +60,7 @@ pub use self::{ import::{import_account, import_accounts, read_geth_accounts}, json::OpaqueKeyFile as KeyFile, parity_wordlist::random_phrase, + presale::PresaleWallet, random::random_string, secret_store::{ Derivation, IndexDerivation, SecretStore, SecretVaultRef, diff --git a/crates/cfx_store/src/presale.rs b/crates/cfx_store/src/presale.rs new file mode 100644 index 0000000000..cd7de3eec4 --- /dev/null +++ b/crates/cfx_store/src/presale.rs @@ -0,0 +1,111 @@ +// Copyright 2015-2020 Parity Technologies (UK) Ltd. +// This file is part of OpenEthereum. + +// OpenEthereum 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. + +// OpenEthereum 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 OpenEthereum. If not, see . + +use cfxkey::Password; +use crypto::{ + self, pbkdf2, + publickey::{Address, KeyPair, Secret}, + Keccak256, +}; +// use cfxkey::Secret; +use json; +use std::{fs, num::NonZeroU32, path::Path}; +use Error; + +/// Pre-sale wallet. +pub struct PresaleWallet { + iv: [u8; 16], + ciphertext: Vec, + address: Address, +} + +impl From for PresaleWallet { + fn from(wallet: json::PresaleWallet) -> Self { + let mut iv = [0u8; 16]; + iv.copy_from_slice(&wallet.encseed[..16]); + + let mut ciphertext = vec![]; + ciphertext.extend_from_slice(&wallet.encseed[16..]); + + let address_bytes: [u8; 20] = wallet.address.into(); + PresaleWallet { + iv, + ciphertext, + address: Address::from(address_bytes), + } + } +} + +impl PresaleWallet { + /// Open a pre-sale wallet. + pub fn open

(path: P) -> Result + where P: AsRef { + let file = fs::File::open(path)?; + let presale = json::PresaleWallet::load(file) + .map_err(|e| Error::InvalidKeyFile(format!("{}", e)))?; + Ok(PresaleWallet::from(presale)) + } + + /// Decrypt the wallet. + pub fn decrypt(&self, password: &Password) -> Result { + let mut derived_key = [0u8; 32]; + let salt = pbkdf2::Salt(password.as_bytes()); + let sec = pbkdf2::Secret(password.as_bytes()); + let iter = NonZeroU32::new(2000).expect("2000 > 0; qed"); + pbkdf2::sha256(iter.get(), salt, sec, &mut derived_key); + + let mut key = vec![0; self.ciphertext.len()]; + let len = crypto::aes::decrypt_128_cbc( + &derived_key[0..16], + &self.iv, + &self.ciphertext, + &mut key, + ) + .map_err(|_| Error::InvalidPassword)?; + let unpadded = &key[..len]; + + let secret = Secret::import_key(&unpadded.keccak256())?; + if let Ok(kp) = KeyPair::from_secret(secret) { + if kp.address() == self.address { + return Ok(kp); + } + } + + Err(Error::InvalidPassword) + } +} + +#[cfg(test)] +mod tests { + use super::PresaleWallet; + use json; + + #[test] + fn test() { + let json = r#" + { + "encseed": "137103c28caeebbcea5d7f95edb97a289ded151b72159137cb7b2671f394f54cff8c121589dcb373e267225547b3c71cbdb54f6e48ec85cd549f96cf0dedb3bc0a9ac6c79b9c426c5878ca2c9d06ff42a23cb648312fc32ba83649de0928e066", + "ethaddr": "ede84640d1a1d3e06902048e67aa7db8d52c2ce1", + "email": "123@gmail.com", + "btcaddr": "1JvqEc6WLhg6GnyrLBe2ztPAU28KRfuseH" + } "#; + + let wallet = json::PresaleWallet::load(json.as_bytes()).unwrap(); + let wallet = PresaleWallet::from(wallet); + assert!(wallet.decrypt(&"123".into()).is_ok()); + assert!(wallet.decrypt(&"124".into()).is_err()); + } +} diff --git a/accounts/cfxstore/src/random.rs b/crates/cfx_store/src/random.rs similarity index 100% rename from accounts/cfxstore/src/random.rs rename to crates/cfx_store/src/random.rs diff --git a/accounts/cfxstore/src/secret_store.rs b/crates/cfx_store/src/secret_store.rs similarity index 100% rename from accounts/cfxstore/src/secret_store.rs rename to crates/cfx_store/src/secret_store.rs diff --git a/accounts/cfxstore/tests/api.rs b/crates/cfx_store/tests/api.rs similarity index 100% rename from accounts/cfxstore/tests/api.rs rename to crates/cfx_store/tests/api.rs diff --git a/accounts/cfxstore/tests/res/ciphertext/30.json b/crates/cfx_store/tests/res/ciphertext/30.json similarity index 100% rename from accounts/cfxstore/tests/res/ciphertext/30.json rename to crates/cfx_store/tests/res/ciphertext/30.json diff --git a/accounts/cfxstore/tests/res/ciphertext/31.json b/crates/cfx_store/tests/res/ciphertext/31.json similarity index 100% rename from accounts/cfxstore/tests/res/ciphertext/31.json rename to crates/cfx_store/tests/res/ciphertext/31.json diff --git a/accounts/cfxstore/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9 b/crates/cfx_store/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9 similarity index 100% rename from accounts/cfxstore/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9 rename to crates/cfx_store/tests/res/geth_keystore/UTC--2016-02-17T09-20-45.721400158Z--3f49624084b67849c7b4e805c5988c21a430f9d9 diff --git a/accounts/cfxstore/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf b/crates/cfx_store/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf similarity index 100% rename from accounts/cfxstore/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf rename to crates/cfx_store/tests/res/geth_keystore/UTC--2016-02-20T09-33-03.984382741Z--5ba4dcf897e97c2bdf8315b9ef26c13c085988cf diff --git a/accounts/cfxstore/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649 b/crates/cfx_store/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649 similarity index 100% rename from accounts/cfxstore/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649 rename to crates/cfx_store/tests/res/geth_keystore/UTC--2016-04-03T08-58-49.834202900Z--63121b431a52f8043c16fcf0d1df9cb7b5f66649 diff --git a/accounts/cfxstore/tests/res/pat/p1.json b/crates/cfx_store/tests/res/pat/p1.json similarity index 100% rename from accounts/cfxstore/tests/res/pat/p1.json rename to crates/cfx_store/tests/res/pat/p1.json diff --git a/accounts/cfxstore/tests/res/pat/p2.json b/crates/cfx_store/tests/res/pat/p2.json similarity index 100% rename from accounts/cfxstore/tests/res/pat/p2.json rename to crates/cfx_store/tests/res/pat/p2.json diff --git a/accounts/cfxstore/tests/util/mod.rs b/crates/cfx_store/tests/util/mod.rs similarity index 100% rename from accounts/cfxstore/tests/util/mod.rs rename to crates/cfx_store/tests/util/mod.rs diff --git a/accounts/cfxstore/tests/util/transient_dir.rs b/crates/cfx_store/tests/util/transient_dir.rs similarity index 100% rename from accounts/cfxstore/tests/util/transient_dir.rs rename to crates/cfx_store/tests/util/transient_dir.rs diff --git a/cfx_types/Cargo.toml b/crates/cfx_types/Cargo.toml similarity index 100% rename from cfx_types/Cargo.toml rename to crates/cfx_types/Cargo.toml diff --git a/cfx_types/src/lib.rs b/crates/cfx_types/src/lib.rs similarity index 98% rename from cfx_types/src/lib.rs rename to crates/cfx_types/src/lib.rs index 906eaac48a..3a9ae689d8 100644 --- a/cfx_types/src/lib.rs +++ b/crates/cfx_types/src/lib.rs @@ -193,6 +193,14 @@ pub mod space_util { } } +pub fn maybe_address(address: &Address) -> Option

{ + if address.is_zero() { + None + } else { + Some(*address) + } +} + /// The KECCAK hash of an empty bloom filter (0x00 * 256) pub const KECCAK_EMPTY_BLOOM: H256 = H256([ 0xd3, 0x97, 0xb3, 0xb0, 0x43, 0xd8, 0x7f, 0xcd, 0x6f, 0xad, 0x12, 0x91, diff --git a/cfx_utils/Cargo.toml b/crates/cfx_utils/Cargo.toml similarity index 100% rename from cfx_utils/Cargo.toml rename to crates/cfx_utils/Cargo.toml diff --git a/cfx_utils/src/cancellable_task_channel.rs b/crates/cfx_utils/src/cancellable_task_channel.rs similarity index 99% rename from cfx_utils/src/cancellable_task_channel.rs rename to crates/cfx_utils/src/cancellable_task_channel.rs index 45fe1617d9..168b76e88e 100644 --- a/cfx_utils/src/cancellable_task_channel.rs +++ b/crates/cfx_utils/src/cancellable_task_channel.rs @@ -185,8 +185,7 @@ impl CancelableTaskSender { fn remove_pending( &self, task_info_locked: &mut TaskInfo, key: &T::Key, notify_waits: bool, - ) -> bool - { + ) -> bool { let queue = &mut *self.queue.write(); let mut found = false; // Remove tasks from queue. @@ -237,8 +236,7 @@ impl CancelableTaskReceiver { &self, try_recv: bool, may_block_indefinitely: bool, task_guard: &mut MutexGuard>, queue_guard: &mut RwLockWriteGuard>>, - ) -> Result> - { + ) -> Result> { match self.receiver.try_recv() { Err(TryRecvError::Disconnected) => { Err(StopOr::RecvError(TryRecvError::Disconnected)) diff --git a/cfx_utils/src/lib.rs b/crates/cfx_utils/src/lib.rs similarity index 100% rename from cfx_utils/src/lib.rs rename to crates/cfx_utils/src/lib.rs diff --git a/core/Cargo.toml b/crates/cfxcore/core/Cargo.toml similarity index 50% rename from core/Cargo.toml rename to crates/cfxcore/core/Cargo.toml index d7a334edfc..a096024147 100644 --- a/core/Cargo.toml +++ b/crates/cfxcore/core/Cargo.toml @@ -3,86 +3,90 @@ description = "Conflux core library" homepage = "https://www.confluxnetwork.org" license = "GPL-3.0" name = "cfxcore" -version = "2.3.4" +version = "2.3.5" edition = "2018" [dependencies] bit-set = "0.4" substrate-bn = { git = "https://github.com/paritytech/bn", default-features = false, rev="63f8c587356a67b33c7396af98e065b66fca5dda" } byteorder = "1.0" -cfxkey = { path = "../accounts/cfxkey" } -cfx-addr = { path = "../cfx_addr/rust" } -cfx-bytes = { path = "../cfx_bytes" } -cfx-math = { path = "../cfx_math"} -cfx-internal-common = { path = "internal_common" } -cfx-parameters = { path = "parameters" } -cfx-statedb = { path = "statedb" } -cfx-state = { path = "state" } -cfx-storage = { path = "storage", optional = true } -cfx-types = { path = "../cfx_types" } -cfx-utils = { path = "../cfx_utils" } -channel = { path = "./src/pos/common/channel"} +cfxkey = { path = "../../cfx_key" } +cfx-addr = { path = "../../cfx_addr" } +cfx-bytes = { path = "../../cfx_bytes" } +cfx-math = { path = "../../cfx_math" } +cfx-internal-common = { path = "../internal_common" } +cfx-parameters = { path = "../parameters" } +cfx-statedb = { path = "../../dbs/statedb" } +cfx-storage = { path = "../../dbs/storage", optional = true } +cfx-vm-tracer-derive = {path= "../../util/cfx-vm-tracer-derive" } +cfx-types = { path = "../../cfx_types" } +cfx-utils = { path = "../../cfx_utils" } +cfx-vm-types = { path = "../vm-types" } +cfx-vm-interpreter = { path = "../vm-interpreter" } +cfx-executor = { path = "../executor" } +cfx-execute-helper = { path = "../execute-helper" } +channel = { path = "src/pos/common/channel" } clap = "2" -dag = {path = "../util/dag"} +dag = {path = "../../util/dag" } derivative = "2.0.2" -db = { path = "../db" } +db = { path = "../../dbs/db" } either = "1.5.3" error-chain = { version = "0.12", default-features = false } fallible-iterator = "0.2" fs_extra = "1.1.0" futures = {version="0.3.3", features = ["compat"]} hashbrown = "0.7.1" -hibitset = { path = "../util/hibitset" } +hibitset = { path = "../../util/hibitset" } itertools = "0.9" -io = { path = "../util/io" } +io = { path = "../../util/io" } jsonrpc-core = "15.1.0" keccak-hash = "0.5" kvdb = "0.4" -kvdb-rocksdb = {path="../db/src/kvdb-rocksdb"} +kvdb-rocksdb = {path= "../../dbs/kvdb-rocksdb" } lazy_static = "1.4" -link-cut-tree = { path = "../util/link-cut-tree" } +link-cut-tree = { path = "../../util/link-cut-tree" } log = "0.4" log4rs = { version = "1.2.0", features = ["background_rotation", "gzip"] } lru_time_cache = "0.9.0" -malloc_size_of = {path = "../util/malloc_size_of"} -malloc_size_of_derive = {path = "../util/malloc_size_of_derive"} +malloc_size_of = {path = "../../util/malloc_size_of" } +malloc_size_of_derive = {path = "../../util/malloc_size_of_derive" } memmap = "0.6" memoffset = "0.5.1" -memory-cache = { path = "../util/memory-cache" } -metrics = { path = "../util/metrics" } -network = { path = "../network" } +memory-cache = { path = "../../util/memory-cache" } +metrics = { path = "../../util/metrics" } +network = { path = "../../network" } num = "0.2" num-traits = { version = "0.2.8", default-features = false } parity-crypto = "0.9.0" parking_lot = "0.11" primal = "0.2.3" -primitives = { path = "../primitives" } -priority-send-queue = { path = "../util/priority-send-queue" } +primitives = { path = "../../primitives" } +priority-send-queue = { path = "../../util/priority-send-queue" } prometheus = { version = "0.7.0", default-features = false } rand = "0.7" rand_08 = {package = "rand", version = "0.8"} rand_xorshift="0.2" -random-crash = { path = "../util/random_crash" } +random-crash = { path = "../../util/random_crash" } rayon = "1.0" rlp = "0.4.0" rlp_derive = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "1597a9cab02343eb2322ca0ac58d39b64e3f42d1" } rustc-hex = "2.1" -secret-store = { path = "../secret_store" } +secret-store = { path = "../../secret_store" } serde = { version = "1.0", features = ["rc"] } serde_derive = "1.0" serde_json = "1.0" siphasher = "0.3" slab = "0.4" -solidity-abi = {path="../util/solidity-abi"} -solidity-abi-derive = {path="../util/solidity-abi-derive"} -sha3-macro = {path="../util/sha3-macro"} +solidity-abi = {path= "../../util/solidity-abi" } +solidity-abi-derive = {path= "../../util/solidity-abi-derive" } +sha3-macro = {path= "../../util/sha3-macro" } sqlite = "0.25" sqlite3-sys = "0.12" static_assertions = "1.1.0" strfmt = "0.1" tempdir = "0.3" threadpool = "1.0" -throttling = { path = "../util/throttling" } +throttling = { path = "../../util/throttling" } toml = "0.5.8" tokio02 = { version = "0.2", package="tokio", features = ["full"] } tokio = { version = "1.6", features = ["full"] } @@ -98,47 +102,50 @@ bcs = "0.1.2" async-trait = "0.1" num-derive = { version = "0.3.3", default-features = false } thiserror = "1.0.24" -fallible = { path = "./src/pos/common/fallible" } +fallible = { path = "src/pos/common/fallible" } mirai-annotations = { version = "1.10.1", default-features = false } -bounded-executor = { path = "./src/pos/common/bounded-executor" } -diem-config = { path = "./src/pos/config" } -diem-crypto = { path = "./src/pos/crypto/crypto" } -diem-infallible = { path = "./src/pos/common/infallible" } -diem-logger = { path = "./src/pos/common/logger" } -diem-metrics = { path = "./src/pos/common/metrics" } -diem-secure-storage = { path = "./src/pos/secure/storage" } -diem-types = { path = "./src/pos/types" } -executor-types = { path = "./src/pos/types/executor-types" } -executor = {path = "./src/pos/consensus/executor"} -consensus-types = { path = "./src/pos/consensus/consensus-types" } -safety-rules = { path = "./src/pos/consensus/safety-rules" } +bounded-executor = { path = "src/pos/common/bounded-executor" } +diem-config = { path = "src/pos/config" } +diem-crypto = { path = "src/pos/crypto/crypto" } +diem-infallible = { path = "src/pos/common/infallible" } +diem-logger = { path = "src/pos/common/logger" } +diem-metrics = { path = "src/pos/common/metrics" } +diem-secure-storage = { path = "src/pos/secure/storage" } +diem-types = { path = "src/pos/types" } +executor-types = { path = "src/pos/types/executor-types" } +executor = {path = "src/pos/consensus/executor" } +consensus-types = { path = "src/pos/consensus/consensus-types" } +safety-rules = { path = "src/pos/consensus/safety-rules" } pos-ledger-db = { path = "src/pos/storage/pos-ledger-db" } cached-pos-ledger-db = { path = "src/pos/storage/cached-pos-ledger-db" } -schemadb = { path = "./src/pos/storage/schemadb" } -storage-interface = { path = "./src/pos/storage/storage-interface" } -short-hex-str = { path = "./src/pos/common/short-hex-str" } -subscription-service = { path = "./src/pos/common/subscription-service" } +schemadb = { path = "src/pos/storage/schemadb" } +storage-interface = { path = "src/pos/storage/storage-interface" } +short-hex-str = { path = "src/pos/common/short-hex-str" } +subscription-service = { path = "src/pos/common/subscription-service" } fail = "0.4.0" anyhow = "1.0.38" once_cell = "1.7.2" -move-core-types = { path = "./src/pos/types/move-core-types"} -pow-types = {path = "./src/pos/types/pow-types"} +move-core-types = { path = "src/pos/types/move-core-types" } +pow-types = {path = "src/pos/types/pow-types" } async-oneshot = "0.5.0" proptest = { version = "1.0.0", optional = true } proptest-derive = { version = "0.3.0", optional = true } -diem-temppath = { path = "./src/pos/common/temppath" } -crash-handler = { path = "../core/src/pos/common/crash-handler" } -heap-map = {path = "../util/heap-map" } -treap-map = {path = "../util/treap-map" } -cfx-packing-pool = { path = "./packing-pool"} +diem-temppath = { path = "src/pos/common/temppath" } +crash-handler = { path = "src/pos/common/crash-handler" } +heap-map = {path = "../../util/heap-map" } +impl-trait-for-tuples = "^0.2" +impl-tools = "^0.10" +treap-map = {path = "../../util/treap-map" } +cfx-packing-pool = { path = "../packing-pool" } [dev-dependencies] criterion = "0.3" -cfx-storage = { path = "storage", features = ["testonly_code"] } +cfx-storage = { path = "../../dbs/storage", features = ["testonly_code"] } +cfx-vm-types = { path = "../vm-types", features = ["testonly_code"] } proptest = "1.0.0" proptest-derive = "0.3.0" -consensus-types = { path = "./src/pos/consensus/consensus-types", features = ["fuzzing"] } +consensus-types = { path = "src/pos/consensus/consensus-types", features = ["fuzzing"] } #tokio = { version = "0.2.11", features = ["time"] } [dependencies.parity-util-mem] diff --git a/core/benchmark/attack/src/main.rs b/crates/cfxcore/core/benchmark/attack/src/main.rs similarity index 100% rename from core/benchmark/attack/src/main.rs rename to crates/cfxcore/core/benchmark/attack/src/main.rs diff --git a/core/benchmark/consensus/Cargo.toml b/crates/cfxcore/core/benchmark/consensus/Cargo.toml similarity index 74% rename from core/benchmark/consensus/Cargo.toml rename to crates/cfxcore/core/benchmark/consensus/Cargo.toml index c24f71319c..be159cb02b 100644 --- a/core/benchmark/consensus/Cargo.toml +++ b/crates/cfxcore/core/benchmark/consensus/Cargo.toml @@ -7,10 +7,10 @@ version = "0.1.0" edition = "2018" [dependencies] -cfxcore = { path = "../../../core" } -cfx-types = { path = "../../../cfx_types" } -primitives = { path = "../../../primitives" } -db = { path = "../../../db" } +cfxcore = { path = "../.." } +cfx-types = { path = "../../../../cfx_types" } +primitives = { path = "../../../../primitives" } +db = { path = "../../../../dbs/db" } threadpool = "1.0" parking_lot = "0.11" log4rs = { version = "1.2.0", features = ["background_rotation", "gzip"] } diff --git a/core/benchmark/consensus/src/main.rs b/crates/cfxcore/core/benchmark/consensus/src/main.rs similarity index 99% rename from core/benchmark/consensus/src/main.rs rename to crates/cfxcore/core/benchmark/consensus/src/main.rs index 3037017f56..a5c20cce65 100644 --- a/core/benchmark/consensus/src/main.rs +++ b/crates/cfxcore/core/benchmark/consensus/src/main.rs @@ -73,8 +73,7 @@ fn check_results( hashes: &Vec, valid_indices: &HashMap, timer_indices: &HashMap, adaptive_indices: &HashMap, -) -{ +) { let mut pending_cnt = 0; let consensus_read = consensus.inner.read(); for i in start..end { diff --git a/core/benchmark/storage/Cargo.toml b/crates/cfxcore/core/benchmark/storage/Cargo.toml similarity index 87% rename from core/benchmark/storage/Cargo.toml rename to crates/cfxcore/core/benchmark/storage/Cargo.toml index e57a95ed92..784f64dc41 100644 --- a/core/benchmark/storage/Cargo.toml +++ b/crates/cfxcore/core/benchmark/storage/Cargo.toml @@ -7,13 +7,13 @@ version = "0.1.0" edition = "2018" [dependencies] -cfxcore = { path = "../../../core", features = ["bls-blst"] } -cfx-types = { path = "../../../cfx_types", features=["storage_benchmark_no_account_space_check"] } -cfx-statedb = { path = "../../../core/statedb" } -cfx-storage = { path = "../../../core/storage" } -cfx-internal-common = { path = "../../../core/internal_common" } +cfxcore = { path = "../..", features = ["bls-blst"] } +cfx-types = { path = "../../../../cfx_types", features=["storage_benchmark_no_account_space_check"] } +cfx-statedb = { path = "../../../../dbs/statedb" } +cfx-storage = { path = "../../../../dbs/storage" } +cfx-internal-common = { path = "../../../internal_common" } clap = "2.32" -db = { path = "../../../db" } +db = { path = "../../../../dbs/db" } env_logger = "0.7" error-chain = "0.12" ethcore = { package = "ethcore", git = "https://github.com/paritytech/parity-ethereum", tag = "v2.4.0" } @@ -26,7 +26,7 @@ kvdb = "0.4" lazy_static = "1.4" log = "0.4" parking_lot = "0.11" -primitives = { path = "../../../primitives" } +primitives = { path = "../../../../primitives" } rlp = { version = "0.3.0", feature = ["ethereum"] } serde_json = "1.0" base64ct = "=1.1.1" diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/Cargo.toml b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/Cargo.toml similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/Cargo.toml rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/Cargo.toml diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/LICENSE b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/LICENSE similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/LICENSE rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/LICENSE diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/README.md b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/README.md similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/README.md rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/README.md diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/benches/bench.rs b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/benches/bench.rs similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/benches/bench.rs rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/benches/bench.rs diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/Cargo.toml b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/Cargo.toml similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/Cargo.toml rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/Cargo.toml diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/build.rs b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/build.rs similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/build.rs rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/build.rs diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/AUTHORS b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/AUTHORS similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/AUTHORS rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/AUTHORS diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CMakeLists.txt b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CMakeLists.txt similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CMakeLists.txt rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CMakeLists.txt diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CONTRIBUTING.md b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CONTRIBUTING.md similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CONTRIBUTING.md rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/CONTRIBUTING.md diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/COPYING b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/COPYING similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/COPYING rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/COPYING diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/NEWS b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/NEWS similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/NEWS rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/NEWS diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/README.md b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/README.md similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/README.md rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/README.md diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/SnappyConfig.cmake b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/SnappyConfig.cmake similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/SnappyConfig.cmake rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/SnappyConfig.cmake diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/config.h.in b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/config.h.in similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/config.h.in rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/cmake/config.h.in diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/format_description.txt b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/format_description.txt similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/format_description.txt rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/format_description.txt diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/framing_format.txt b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/framing_format.txt similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/framing_format.txt rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/framing_format.txt diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.cc b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.cc similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.cc rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.cc diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.h b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.h similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.h rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-c.h diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-internal.h b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-internal.h similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-internal.h rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-internal.h diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.cc b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.cc similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.cc rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.cc diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.h b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.h similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.h rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-sinksource.h diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.cc b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.cc similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.cc rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.cc diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.h b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.h similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.h rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-internal.h diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-public.h.in b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-public.h.in similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-public.h.in rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-stubs-public.h.in diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.cc b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.cc similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.cc rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.cc diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.h b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.h similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.h rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy-test.h diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.cc b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.cc similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.cc rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.cc diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.h b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.h similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.h rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy.h diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy_unittest.cc b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy_unittest.cc similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy_unittest.cc rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/snappy_unittest.cc diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/alice29.txt b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/alice29.txt similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/alice29.txt rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/alice29.txt diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/asyoulik.txt b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/asyoulik.txt similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/asyoulik.txt rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/asyoulik.txt diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata1.snappy b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata1.snappy similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata1.snappy rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata1.snappy diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata2.snappy b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata2.snappy similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata2.snappy rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata2.snappy diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata3.snappy b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata3.snappy similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata3.snappy rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/baddata3.snappy diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/fireworks.jpeg b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/fireworks.jpeg similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/fireworks.jpeg rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/fireworks.jpeg diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/geo.protodata b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/geo.protodata similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/geo.protodata rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/geo.protodata diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html_x_4 b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html_x_4 similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html_x_4 rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/html_x_4 diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/kppkn.gtb b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/kppkn.gtb similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/kppkn.gtb rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/kppkn.gtb diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/lcet10.txt b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/lcet10.txt similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/lcet10.txt rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/lcet10.txt diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/paper-100k.pdf b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/paper-100k.pdf similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/paper-100k.pdf rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/paper-100k.pdf diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/plrabn12.txt b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/plrabn12.txt similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/plrabn12.txt rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/plrabn12.txt diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/urls.10K b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/urls.10K similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/urls.10K rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/snappy/testdata/urls.10K diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/src/lib.rs b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/src/lib.rs similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/src/lib.rs rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/snappy-sys/src/lib.rs diff --git a/core/benchmark/storage/parity-snappy/rust-snappy/src/lib.rs b/crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/src/lib.rs similarity index 100% rename from core/benchmark/storage/parity-snappy/rust-snappy/src/lib.rs rename to crates/cfxcore/core/benchmark/storage/parity-snappy/rust-snappy/src/lib.rs diff --git a/core/benchmark/storage/src/errors.rs b/crates/cfxcore/core/benchmark/storage/src/errors.rs similarity index 100% rename from core/benchmark/storage/src/errors.rs rename to crates/cfxcore/core/benchmark/storage/src/errors.rs diff --git a/core/benchmark/storage/src/main.rs b/crates/cfxcore/core/benchmark/storage/src/main.rs similarity index 100% rename from core/benchmark/storage/src/main.rs rename to crates/cfxcore/core/benchmark/storage/src/main.rs diff --git a/core/examples/snapshot_merge_test.rs b/crates/cfxcore/core/examples/snapshot_merge_test.rs similarity index 99% rename from core/examples/snapshot_merge_test.rs rename to crates/cfxcore/core/examples/snapshot_merge_test.rs index 28f4336b6b..3715f408f6 100644 --- a/core/examples/snapshot_merge_test.rs +++ b/crates/cfxcore/core/examples/snapshot_merge_test.rs @@ -337,8 +337,7 @@ fn prepare_state( accounts: usize, accounts_per_epoch: usize, account_map: &mut HashMap, old_state_root: &StateRootWithAuxInfo, state_root: &StateRootWithAuxInfo, -) -> Result<(H256, MerkleHash), StorageError> -{ +) -> Result<(H256, MerkleHash), StorageError> { let mut new_account_map = HashMap::new(); for i in 0..accounts { let addr = Address::random().with_native_space(); @@ -364,8 +363,7 @@ fn add_accounts( accounts_per_epoch: usize, new_account_map: &HashMap, old_state_root: &StateRootWithAuxInfo, state_root: &StateRootWithAuxInfo, -) -> Result<(H256, MerkleHash), StorageError> -{ +) -> Result<(H256, MerkleHash), StorageError> { let accounts = new_account_map.len(); println!("begin to add {} accounts for snapshot...", accounts); let start = Instant::now(); diff --git a/core/src/block_data_manager/block_data_types.rs b/crates/cfxcore/core/src/block_data_manager/block_data_types.rs similarity index 98% rename from core/src/block_data_manager/block_data_types.rs rename to crates/cfxcore/core/src/block_data_manager/block_data_types.rs index de62876e52..1b86f19ac3 100644 --- a/core/src/block_data_manager/block_data_types.rs +++ b/crates/cfxcore/core/src/block_data_manager/block_data_types.rs @@ -1,4 +1,4 @@ -use crate::observer::trace::BlockExecTraces; +use cfx_execute_helper::exec_tracer::BlockExecTraces; use cfx_internal_common::{DatabaseDecodable, DatabaseEncodable}; use cfx_types::{Address, Bloom, H256, U256}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; @@ -50,7 +50,9 @@ impl Decodable for BlockExecutionResult { } } -#[derive(RlpEncodable, RlpDecodable, Clone, Copy, Debug, DeriveMallocSizeOf)] +#[derive( + RlpEncodable, RlpDecodable, Clone, Copy, Debug, DeriveMallocSizeOf, +)] pub struct BlockRewardResult { pub total_reward: U256, pub base_reward: U256, @@ -343,8 +345,7 @@ impl PosRewardInfo { pub fn new( account_reward_list: Vec<(Address, H256, U256)>, execution_epoch_hash: H256, - ) -> Self - { + ) -> Self { let account_rewards = account_reward_list .into_iter() .map(|(address, pos_identifier, reward)| PosRewardForAccount { diff --git a/core/src/block_data_manager/db_gc_manager.rs b/crates/cfxcore/core/src/block_data_manager/db_gc_manager.rs similarity index 100% rename from core/src/block_data_manager/db_gc_manager.rs rename to crates/cfxcore/core/src/block_data_manager/db_gc_manager.rs diff --git a/core/src/block_data_manager/db_manager.rs b/crates/cfxcore/core/src/block_data_manager/db_manager.rs similarity index 100% rename from core/src/block_data_manager/db_manager.rs rename to crates/cfxcore/core/src/block_data_manager/db_manager.rs diff --git a/core/src/block_data_manager/mod.rs b/crates/cfxcore/core/src/block_data_manager/mod.rs similarity index 98% rename from core/src/block_data_manager/mod.rs rename to crates/cfxcore/core/src/block_data_manager/mod.rs index cb06586d1d..c967783ec7 100644 --- a/core/src/block_data_manager/mod.rs +++ b/crates/cfxcore/core/src/block_data_manager/mod.rs @@ -9,6 +9,7 @@ use crate::{ ext_db::SystemDB, pow::{PowComputer, TargetDifficultyManager}, }; +use cfx_executor::internal_contract::make_staking_events; use cfx_storage::{ state_manager::StateIndex, utils::guarded_value::*, StorageManager, StorageManagerTrait, @@ -19,7 +20,7 @@ use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf; use parking_lot::{Mutex, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard}; use primitives::{ block::CompactBlock, - receipt::{BlockReceipts, TransactionOutcome}, + receipt::{BlockReceipts, TransactionStatus}, Block, BlockHeader, EpochId, Receipt, SignedTransaction, TransactionIndex, TransactionWithSignature, NULL_EPOCH, }; @@ -38,12 +39,12 @@ use crate::{ db_manager::DBManager, tx_data_manager::TransactionDataManager, }, consensus::pos_handler::PosVerifier, - executive::internal_contract::{ - build_bloom_and_recover_phantom, decode_register_info, - }, - observer::trace::{BlockExecTraces, TransactionExecTraces}, }; pub use block_data_types::*; +use cfx_execute_helper::{ + exec_tracer::{BlockExecTraces, TransactionExecTraces}, + phantom_tx::build_bloom_and_recover_phantom, +}; use cfx_internal_common::{ EpochExecutionCommitment, StateAvailabilityBoundary, StateRootWithAuxInfo, }; @@ -113,12 +114,12 @@ pub struct BlockDataManager { /// It is also used for checking whether an epoch has been executed. /// It can be updated, i.e., adding new items, in the following cases: /// 1) When a new epoch gets executed in normal execution; - /// 2) After syncing snapshot, we need to update execution commitment - /// for pivot blocks around snapshot block based on blaming information; + /// 2) After syncing snapshot, we need to update execution commitment for + /// pivot blocks around snapshot block based on blaming information; /// 3) After recovering block graph from db, update execution commitment /// from db; - /// 4) In BlockDataManager::new(), update execution commitment - /// of true_genesis_block. + /// 4) In BlockDataManager::new(), update execution commitment of + /// true_genesis_block. epoch_execution_commitments: RwLock>, epoch_execution_contexts: RwLock>, @@ -149,9 +150,9 @@ pub struct BlockDataManager { /// The upper bound always equal to latest executed epoch height. /// As for the lower bound: /// 1. For archive node, it always equals `cur_era_stable_height`. - /// 2. For full node, it equals the height of remotely synchronized - /// state at start, and equals `cur_era_stable_height` after making a - /// new checkpoint. + /// 2. For full node, it equals the height of remotely synchronized state + /// at start, and equals `cur_era_stable_height` after making a new + /// checkpoint. /// /// The lower boundary height will be updated when: /// 1. New checkpoint @@ -173,8 +174,7 @@ impl BlockDataManager { storage_manager: Arc, worker_pool: Arc>, config: DataManagerConfiguration, pow: Arc, - ) -> Self - { + ) -> Self { let mb = 1024 * 1024; let max_cache_size = cache_conf.ledger_mb() * mb; let pref_cache_size = max_cache_size * 3 / 4; @@ -519,8 +519,7 @@ impl BlockDataManager { pub fn block_traces_by_hash_with_epoch( &self, hash: &H256, assumed_epoch: &H256, update_pivot_assumption: bool, update_cache: bool, - ) -> Option - { + ) -> Option { self.get_version( hash, assumed_epoch, @@ -540,8 +539,7 @@ impl BlockDataManager { pub fn insert_block_traces( &self, hash: H256, trace: BlockExecTraces, pivot_hash: H256, persistent: bool, - ) - { + ) { trace! {"insert_block_traces start pivot={:?}", pivot_hash}; self.insert_version( hash, @@ -643,8 +641,7 @@ impl BlockDataManager { pub fn block_execution_result_by_hash_with_epoch( &self, hash: &H256, assumed_epoch: &H256, update_pivot_assumption: bool, update_cache: bool, - ) -> Option - { + ) -> Option { self.get_version( hash, assumed_epoch, @@ -683,8 +680,7 @@ impl BlockDataManager { pub fn insert_block_execution_result( &self, hash: H256, epoch: H256, block_receipts: Arc, persistent: bool, - ) - { + ) { trace! {"insert_block_traces start pivot={:?}", epoch}; let bloom = block_receipts @@ -715,8 +711,7 @@ impl BlockDataManager { pub fn insert_block_reward_result( &self, hash: H256, epoch: &H256, block_reward: BlockRewardResult, persistent: bool, - ) - { + ) { self.insert_version( hash, epoch, @@ -734,8 +729,7 @@ impl BlockDataManager { pub fn block_reward_result_by_hash_with_epoch( &self, hash: &H256, assumed_epoch_later: &H256, update_pivot_assumption: bool, update_cache: bool, - ) -> Option - { + ) -> Option { self.get_version( hash, assumed_epoch_later, @@ -1131,8 +1125,7 @@ impl BlockDataManager { &self, block_hash: H256, state_root_with_aux_info: StateRootWithAuxInfo, receipts_root: H256, logs_bloom_hash: H256, - ) - { + ) { let commitment = EpochExecutionCommitment { state_root_with_aux_info, receipts_root, @@ -1233,8 +1226,7 @@ impl BlockDataManager { on_local_pivot: bool, update_trace: bool, reward_execution_info: &Option, pos_verifier: &PosVerifier, evm_chain_id: u32, - ) -> bool - { + ) -> bool { if !self.epoch_executed(epoch_hash) { return false; } @@ -1293,7 +1285,7 @@ impl BlockDataManager { } Space::Ethereum if *outcome_status - != TransactionOutcome::Skipped => + != TransactionStatus::Skipped => { let rpc_index = evm_tx_index; evm_tx_index += 1; @@ -1306,8 +1298,8 @@ impl BlockDataManager { build_bloom_and_recover_phantom(logs, tx.hash()); match outcome_status { - TransactionOutcome::Success - | TransactionOutcome::Failure => { + TransactionStatus::Success + | TransactionStatus::Failure => { self.insert_transaction_index( &tx.hash, &TransactionIndex { @@ -1332,11 +1324,8 @@ impl BlockDataManager { evm_tx_index += 1; } - for log in logs { - if let Some(event) = decode_register_info(log) { - epoch_staking_events.push(event); - } - } + epoch_staking_events + .extend(make_staking_events(logs)); } _ => {} } @@ -1821,8 +1810,7 @@ impl DataManagerConfiguration { pub fn new( persist_tx_index: bool, persist_block_number_index: bool, tx_cache_index_maintain_timeout: Duration, db_type: DbType, - ) -> Self - { + ) -> Self { Self { persist_tx_index, persist_block_number_index, diff --git a/core/src/block_data_manager/tx_data_manager.rs b/crates/cfxcore/core/src/block_data_manager/tx_data_manager.rs similarity index 99% rename from core/src/block_data_manager/tx_data_manager.rs rename to crates/cfxcore/core/src/block_data_manager/tx_data_manager.rs index 6382008533..40ab3cf186 100644 --- a/core/src/block_data_manager/tx_data_manager.rs +++ b/crates/cfxcore/core/src/block_data_manager/tx_data_manager.rs @@ -35,8 +35,7 @@ impl TransactionDataManager { pub fn new( tx_cache_index_maintain_timeout: Duration, worker_pool: Arc>, - ) -> Self - { + ) -> Self { Self { tx_time_window: RwLock::new(TransactionCacheContainer::new( tx_cache_index_maintain_timeout.as_secs(), diff --git a/core/src/cache_config.rs b/crates/cfxcore/core/src/cache_config.rs similarity index 98% rename from core/src/cache_config.rs rename to crates/cfxcore/core/src/cache_config.rs index fe011fa5dc..0d57e427cd 100644 --- a/core/src/cache_config.rs +++ b/crates/cfxcore/core/src/cache_config.rs @@ -37,8 +37,7 @@ impl CacheConfig { pub fn new( ledger: usize, invalid_block_hashes_cache_size_in_count: usize, target_difficulties_cache_size_in_count: usize, - ) -> Self - { + ) -> Self { CacheConfig { ledger, invalid_block_hashes_cache_size_in_count, diff --git a/core/src/cache_manager.rs b/crates/cfxcore/core/src/cache_manager.rs similarity index 99% rename from core/src/cache_manager.rs rename to crates/cfxcore/core/src/cache_manager.rs index ec28b9422d..d7b5e8bfcb 100644 --- a/core/src/cache_manager.rs +++ b/crates/cfxcore/core/src/cache_manager.rs @@ -61,8 +61,7 @@ where T: Eq + Hash pub fn new( pref_cache_size: usize, max_cache_size: usize, bytes_per_cache_entry: usize, - ) -> Self - { + ) -> Self { CacheManager { pref_cache_size, max_cache_size, diff --git a/core/src/channel.rs b/crates/cfxcore/core/src/channel.rs similarity index 100% rename from core/src/channel.rs rename to crates/cfxcore/core/src/channel.rs diff --git a/core/src/client/chain_notify.rs b/crates/cfxcore/core/src/client/chain_notify.rs similarity index 100% rename from core/src/client/chain_notify.rs rename to crates/cfxcore/core/src/client/chain_notify.rs diff --git a/core/src/client/mod.rs b/crates/cfxcore/core/src/client/mod.rs similarity index 100% rename from core/src/client/mod.rs rename to crates/cfxcore/core/src/client/mod.rs diff --git a/core/src/consensus/anticone_cache.rs b/crates/cfxcore/core/src/consensus/anticone_cache.rs similarity index 100% rename from core/src/consensus/anticone_cache.rs rename to crates/cfxcore/core/src/consensus/anticone_cache.rs diff --git a/core/src/consensus/consensus_inner/blame_verifier.rs b/crates/cfxcore/core/src/consensus/consensus_inner/blame_verifier.rs similarity index 100% rename from core/src/consensus/consensus_inner/blame_verifier.rs rename to crates/cfxcore/core/src/consensus/consensus_inner/blame_verifier.rs diff --git a/core/src/consensus/consensus_inner/confirmation_meter.rs b/crates/cfxcore/core/src/consensus/consensus_inner/confirmation_meter.rs similarity index 99% rename from core/src/consensus/consensus_inner/confirmation_meter.rs rename to crates/cfxcore/core/src/consensus/consensus_inner/confirmation_meter.rs index e9d1dd408a..27a9b20de7 100644 --- a/core/src/consensus/consensus_inner/confirmation_meter.rs +++ b/crates/cfxcore/core/src/consensus/consensus_inner/confirmation_meter.rs @@ -178,8 +178,7 @@ impl ConfirmationMeter { fn confirmation_risk( &self, g_inner: &ConsensusGraphInner, w_0: i128, w_4: i128, epoch_num: u64, - ) -> f64 - { + ) -> f64 { // Compute w_1 let idx = g_inner.get_pivot_block_arena_index(epoch_num); let pivot_idx = g_inner.height_to_pivot_index(epoch_num); diff --git a/core/src/consensus/consensus_inner/consensus_executor.rs b/crates/cfxcore/core/src/consensus/consensus_inner/consensus_executor.rs similarity index 88% rename from core/src/consensus/consensus_inner/consensus_executor.rs rename to crates/cfxcore/core/src/consensus/consensus_inner/consensus_executor.rs index 5634ccfbd4..d913aff919 100644 --- a/core/src/consensus/consensus_inner/consensus_executor.rs +++ b/crates/cfxcore/core/src/consensus/consensus_inner/consensus_executor.rs @@ -22,10 +22,7 @@ use rustc_hex::ToHex; use cfx_internal_common::{ debug::*, EpochExecutionCommitment, StateRootWithAuxInfo, }; -use cfx_parameters::{ - consensus::*, consensus_internal::CIP107_STORAGE_POINT_PROP_INIT, -}; -use cfx_state::CleanupMode; +use cfx_parameters::consensus::*; use cfx_statedb::{ErrorKind as DbErrorKind, Result as DbResult, StateDb}; use cfx_storage::{ defaults::DEFAULT_EXECUTION_PREFETCH_THREADS, StateIndex, @@ -37,9 +34,8 @@ use cfx_types::{ }; use metrics::{register_meter_with_group, Meter, MeterTimer}; use primitives::{ - compute_block_number, - receipt::{BlockReceipts, Receipt, TransactionOutcome}, - Action, Block, BlockHeaderBuilder, BlockNumber, EpochId, SignedTransaction, + compute_block_number, receipt::BlockReceipts, Action, Block, + BlockHeaderBuilder, BlockNumber, EpochId, SignedTransaction, TransactionIndex, MERKLE_NULL_NODE, }; @@ -53,33 +49,35 @@ use crate::{ pos_handler::PosVerifier, ConsensusGraphInner, }, - evm::Spec, - executive::{ - internal_contract::{ - build_bloom_and_recover_phantom, decode_register_info, - storage_point_prop, - }, - revert_reason_decode, EstimateRequest, ExecutionError, - ExecutionOutcome, Executive, TransactOptions, - }, - machine::Machine, - observer::trace::{ExecTrace, TransactionExecTraces}, rpc_errors::{invalid_params_check, Result as RpcResult}, - spec::genesis::initialize_internal_contract_accounts, - state::{ - distribute_pos_interest, initialize_or_update_dao_voted_params, - prefetcher::{ - prefetch_accounts, ExecutionStatePrefetcher, PrefetchTaskHandle, - }, - update_pos_status, State, + state_prefetcher::{ + prefetch_accounts, ExecutionStatePrefetcher, PrefetchTaskHandle, }, verification::{ compute_receipts_root, VerificationConfig, VerifyTxLocalMode, VerifyTxMode, }, - vm::{Env, Error as VmErr}, SharedTransactionPool, }; +use cfx_execute_helper::{ + estimation::{EstimateExt, EstimateRequest, EstimationContext}, + exec_tracer::TransactionExecTraces, + observer::Observer, + tx_outcome::make_process_tx_outcome, +}; +use cfx_executor::{ + executive::{ + ExecutionOutcome, ExecutiveContext, TransactOptions, TransactSettings, + }, + internal_contract::initialize_internal_contract_accounts, + machine::Machine, + state::{ + distribute_pos_interest, initialize_cip107, + initialize_or_update_dao_voted_params, update_pos_status, CleanupMode, + State, + }, +}; +use cfx_vm_types::{Env, Spec}; lazy_static! { static ref CONSENSIS_EXECUTION_TIMER: Arc = @@ -150,8 +148,7 @@ impl EpochExecutionTask { epoch_arena_index: usize, inner: &ConsensusGraphInner, reward_execution_info: Option, on_local_pivot: bool, force_recompute: bool, - ) -> Self - { + ) -> Self { Self { epoch_hash: inner.arena[epoch_arena_index].hash, epoch_block_hashes: inner.get_epoch_block_hashes(epoch_arena_index), @@ -198,8 +195,7 @@ impl ConsensusExecutor { config: ConsensusExecutionConfiguration, verification_config: VerificationConfig, bench_mode: bool, pos_verifier: Arc, - ) -> Arc - { + ) -> Arc { let machine = tx_pool.machine(); let handler = Arc::new(ConsensusExecutionHandler::new( tx_pool, @@ -383,8 +379,7 @@ impl ConsensusExecutor { pub fn get_reward_execution_info_from_index( &self, inner: &mut ConsensusGraphInner, reward_index: Option<(usize, usize)>, - ) -> Option - { + ) -> Option { reward_index.map( |(pivot_arena_index, anticone_penalty_cutoff_epoch_arena_index)| { // We have to wait here because blame information will determine the reward of each block. @@ -557,8 +552,7 @@ impl ConsensusExecutor { pub fn get_blame_and_deferred_state_for_generation( &self, parent_block_hash: &H256, inner_lock: &RwLock, - ) -> Result - { + ) -> Result { let (parent_arena_index, last_state_block) = { let inner = inner_lock.read(); let parent_opt = inner.hash_to_arena_indices.get(parent_block_hash); @@ -621,8 +615,7 @@ impl ConsensusExecutor { &self, task: EpochExecutionTask, debug_record: Option<&mut ComputeEpochDebugRecord>, recover_mpt_during_construct_pivot_state: bool, - ) - { + ) { if !self.consensus_graph_bench_mode { self.handler.handle_epoch_execution( task, @@ -636,8 +629,7 @@ impl ConsensusExecutor { &self, epoch_hash: &H256, epoch_block_hashes: &Vec, on_local_pivot: bool, reward_execution_info: &Option, epoch_height: u64, - ) -> bool - { + ) -> bool { self.handler.epoch_executed_and_recovered( epoch_hash, epoch_block_hashes, @@ -650,8 +642,7 @@ impl ConsensusExecutor { pub fn call_virtual( &self, tx: &SignedTransaction, epoch_id: &H256, epoch_size: usize, request: EstimateRequest, - ) -> RpcResult - { + ) -> RpcResult<(ExecutionOutcome, EstimateExt)> { self.handler.call_virtual(tx, epoch_id, epoch_size, request) } @@ -841,8 +832,7 @@ impl ConsensusExecutionHandler { config: ConsensusExecutionConfiguration, verification_config: VerificationConfig, machine: Arc, pos_verifier: Arc, - ) -> Self - { + ) -> Self { ConsensusExecutionHandler { tx_pool, data_man, @@ -885,8 +875,7 @@ impl ConsensusExecutionHandler { &self, task: EpochExecutionTask, debug_record: Option<&mut ComputeEpochDebugRecord>, recover_mpt_during_construct_pivot_state: bool, - ) - { + ) { let _timer = MeterTimer::time_func(CONSENSIS_EXECUTION_TIMER.as_ref()); self.compute_epoch( &task.epoch_hash, @@ -922,8 +911,7 @@ impl ConsensusExecutionHandler { &self, epoch_hash: &H256, epoch_block_hashes: &Vec, on_local_pivot: bool, reward_execution_info: &Option, epoch_height: u64, - ) -> bool - { + ) -> bool { // note: the lock on chain_id is never held so this should be OK. let evm_chain_id = self .machine @@ -963,8 +951,7 @@ impl ConsensusExecutionHandler { mut debug_record: Option<&mut ComputeEpochDebugRecord>, force_recompute: bool, recover_mpt_during_construct_pivot_state: bool, - ) - { + ) { // FIXME: Question: where to calculate if we should make a snapshot? // FIXME: Currently we make the snapshotting decision when committing // FIXME: a new state. @@ -1158,15 +1145,16 @@ impl ConsensusExecutionHandler { // FIXME: We may want to propagate the error up. let state_root; if on_local_pivot { - state_root = state + let commit_result = state .commit(*epoch_hash, debug_record.as_deref_mut()) .expect(&concat!(file!(), ":", line!(), ":", column!())); + state_root = commit_result.state_root; + let accounts_for_txpool = commit_result.accounts_for_txpool; { debug!("Notify epoch[{}]", epoch_hash); // TODO: use channel to deliver the message. let txpool_clone = self.tx_pool.clone(); - let accounts_for_txpool = state.accounts_for_txpool(); std::thread::Builder::new() .name("txpool_update_state".into()) .spawn(move || { @@ -1175,6 +1163,7 @@ impl ConsensusExecutionHandler { }) .expect("can not notify tx pool to start state"); } + self.tx_pool .set_best_executed_epoch(StateIndex::new_for_readonly( epoch_hash, @@ -1182,9 +1171,10 @@ impl ConsensusExecutionHandler { )) .expect(&concat!(file!(), ":", line!(), ":", column!())); } else { - state_root = state + let commit_result = state .commit(*epoch_hash, debug_record) .expect(&concat!(file!(), ":", line!(), ":", column!())); + state_root = commit_result.state_root; }; self.data_man.insert_epoch_execution_commitment( @@ -1212,8 +1202,7 @@ impl ConsensusExecutionHandler { &self, epoch_id: EpochId, state: &mut State, epoch_blocks: &Vec>, start_block_number: u64, on_local_pivot: bool, - ) -> DbResult>> - { + ) -> DbResult>> { // Prefetch accounts for transactions. // The return value _prefetch_join_handles is used to join all threads // before the exit of this function. @@ -1286,7 +1275,10 @@ impl ConsensusExecutionHandler { .and_then(|hash| self.data_man.block_header_by_hash(&hash)) .map(|header| header.height()); + let epoch_height = pivot_block.block_header.height(); + let chain_id = self.machine.params().chain_id_map(epoch_height); let mut env = Env { + chain_id, number: block_number, author: block.block_header.author().clone(), timestamp: pivot_block.block_header.timestamp(), @@ -1294,7 +1286,7 @@ impl ConsensusExecutionHandler { accumulated_gas_used: U256::zero(), last_hash: last_block_hash, gas_limit: U256::from(block.block_header.gas_limit()), - epoch_height: pivot_block.block_header.height(), + epoch_height, pos_view: pos_view_number, finalized_epoch: pivot_decision_epoch, transaction_epoch_bound: self @@ -1305,6 +1297,8 @@ impl ConsensusExecutionHandler { if !spec.cip43_contract { state.bump_block_number_accumulate_interest(); } + let machine = self.machine.as_ref(); + let secondary_reward = state.secondary_reward(); state.inc_distributable_pos_interest(env.number)?; initialize_internal_contract_accounts( @@ -1317,164 +1311,57 @@ impl ConsensusExecutionHandler { let mut block_traces: Vec = Default::default(); for (idx, transaction) in block.transactions.iter().enumerate() { - let tx_outcome_status; - let mut transaction_logs = Vec::new(); - let mut storage_released = Vec::new(); - let mut storage_collateralized = Vec::new(); - - let options = if self.config.executive_trace { - TransactOptions::exec_with_tracing() + let observer = if self.config.executive_trace { + Observer::with_tracing() } else { - TransactOptions::exec_with_no_tracing() + Observer::with_no_tracing() }; - let r = - Executive::new(state, &env, self.machine.as_ref(), &spec) + let options = TransactOptions { + observer, + settings: TransactSettings::all_checks(), + }; + let execution_outcome = + ExecutiveContext::new(state, &env, machine, &spec) .transact(transaction, options)?; + execution_outcome.log(transaction, &block.hash()); + let r = make_process_tx_outcome( + execution_outcome, + &mut env.accumulated_gas_used, + transaction.hash, + ); - let gas_fee; - let mut gas_sponsor_paid = false; - let mut storage_sponsor_paid = false; - let tx_exec_error_msg: String; - match r { - ExecutionOutcome::NotExecutedDrop(e) => { - tx_outcome_status = TransactionOutcome::Skipped; - tx_exec_error_msg = "tx not executed".into(); - trace!( - "tx not executed, not to reconsider packing: \ - transaction={:?},err={:?}", - transaction, - e - ); - gas_fee = U256::zero(); - if self.config.executive_trace { - block_traces.push(Vec::::new().into()); - } - } - ExecutionOutcome::NotExecutedToReconsiderPacking(e) => { - tx_outcome_status = TransactionOutcome::Skipped; - tx_exec_error_msg = "tx not executed".into(); - trace!( - "tx not executed, to reconsider packing: \ - transaction={:?}, err={:?}", - transaction, - e - ); - if on_local_pivot { - trace!( - "To re-add transaction to transaction pool. \ - transaction={:?}", - transaction - ); - to_pending.push(transaction.clone()) - } - gas_fee = U256::zero(); - if self.config.executive_trace { - block_traces.push(Vec::::new().into()); - } - } - ExecutionOutcome::ExecutionErrorBumpNonce( - error, - executed, - ) => { - tx_outcome_status = TransactionOutcome::Failure; - tx_exec_error_msg = if error - == ExecutionError::VmError(VmErr::Reverted) - { - format!( - "Vm reverted, {}", - revert_reason_decode(&executed.output) - ) - } else { - format!("{:?}", error) - }; - env.accumulated_gas_used += executed.gas_used; - gas_fee = executed.fee; - if self.config.executive_trace { - block_traces.push(executed.trace.into()); - } - if spec.cip78a { - gas_sponsor_paid = executed.gas_sponsor_paid; - storage_sponsor_paid = - executed.storage_sponsor_paid; - } - debug!( - "tx execution error: err={:?}, transaction={:?}", - error, transaction - ); - } - ExecutionOutcome::Finished(executed) => { - tx_outcome_status = TransactionOutcome::Success; - tx_exec_error_msg = String::default(); - GOOD_TPS_METER.mark(1); - - env.accumulated_gas_used += executed.gas_used; - gas_fee = executed.fee; - transaction_logs = executed.logs.clone(); - storage_collateralized = - executed.storage_collateralized.clone(); - storage_released = executed.storage_released.clone(); - - gas_sponsor_paid = executed.gas_sponsor_paid; - storage_sponsor_paid = executed.storage_sponsor_paid; + if r.receipt.tx_success() { + GOOD_TPS_METER.mark(1); + } - trace!("tx executed successfully: result={:?}, transaction={:?}, in block {:?}", executed, transaction, block.hash()); + if on_local_pivot && r.consider_repacked { + to_pending.push(transaction.clone()) + } - if self.config.executive_trace { - block_traces.push(executed.trace.into()); - } + let not_skipped = !r.receipt.tx_skipped(); - if self.pos_verifier.pos_option().is_some() { - trace!("Check {} events", transaction_logs.len()); - for log in &transaction_logs { - if let Some(staking_event) = - decode_register_info(log) - { - epoch_staking_events.push(staking_event); - } - } - trace!("Check events ends"); - } - } + if self.config.executive_trace { + block_traces.push(r.tx_traces.into()); } - let (phantom_txs, log_bloom) = build_bloom_and_recover_phantom( - &transaction_logs, - transaction.hash, - ); - - let receipt = Receipt::new( - tx_outcome_status, - env.accumulated_gas_used, - gas_fee, - gas_sponsor_paid, - transaction_logs, - log_bloom, - storage_sponsor_paid, - storage_collateralized, - storage_released, - ); - receipts.push(receipt); - tx_exec_error_messages.push(tx_exec_error_msg); + receipts.push(r.receipt); + tx_exec_error_messages.push(r.tx_exec_error_msg); + epoch_staking_events.extend(r.tx_staking_events); + let get_and_bump = |index: &mut usize| { + let output = *index; + *index += 1; + output + }; let rpc_index = match transaction.space() { - Space::Native => { - let rpc_index = cfx_tx_index; - cfx_tx_index += 1; - rpc_index - } - Space::Ethereum - if tx_outcome_status != TransactionOutcome::Skipped => - { - let rpc_index = evm_tx_index; - evm_tx_index += 1; - rpc_index + Space::Native => get_and_bump(&mut cfx_tx_index), + Space::Ethereum if not_skipped => { + get_and_bump(&mut evm_tx_index) } _ => usize::MAX, // this will not be used }; - if on_local_pivot - && tx_outcome_status != TransactionOutcome::Skipped - { + if on_local_pivot && not_skipped { let hash = transaction.hash(); self.data_man.insert_transaction_index( @@ -1487,15 +1374,7 @@ impl ConsensusExecutionHandler { }, ); - // note: the lock on chain_id is never held - // so this should be OK. - let evm_chain_id = self - .machine - .params() - .chain_id - .read() - .get_chain_id(env.epoch_height) - .in_evm_space(); + let evm_chain_id = env.chain_id[&Space::Ethereum]; // persist tx index for phantom transactions. // note: in some cases, pivot chain reorgs will result in @@ -1503,7 +1382,7 @@ impl ConsensusExecutionHandler { // same Conflux space tx. we do not remove invalidated // hashes here, but leave it up to the RPC layer to handle // this instead. - for ptx in phantom_txs { + for ptx in r.phantom_txs { self.data_man.insert_transaction_index( &ptx.into_eip155(evm_chain_id).hash(), &TransactionIndex { @@ -1586,8 +1465,7 @@ impl ConsensusExecutionHandler { &self, state: &mut State, reward_info: &RewardExecutionInfo, epoch_later: &H256, on_local_pivot: bool, mut debug_record: Option<&mut ComputeEpochDebugRecord>, spec: Spec, - ) - { + ) { /// (Fee, SetOfPackingBlockHash) struct TxExecutionInfo(U256, BTreeSet); @@ -1894,8 +1772,7 @@ impl ConsensusExecutionHandler { fn recompute_states( &self, pivot_hash: &H256, epoch_blocks: &Vec>, start_block_number: u64, - ) -> DbResult>> - { + ) -> DbResult>> { debug!( "Recompute receipts epoch_id={}, block_count={}", pivot_hash, @@ -1937,8 +1814,7 @@ impl ConsensusExecutionHandler { pub fn call_virtual( &self, tx: &SignedTransaction, epoch_id: &H256, epoch_size: usize, request: EstimateRequest, - ) -> RpcResult - { + ) -> RpcResult<(ExecutionOutcome, EstimateExt)> { let best_block_header = self.data_man.block_header_by_hash(epoch_id); if best_block_header.is_none() { bail!("invalid epoch id"); @@ -2012,6 +1888,7 @@ impl ConsensusExecutionHandler { }; let env = Env { + chain_id: self.machine.params().chain_id_map(block_height), number: start_block_number, author: miner, timestamp: time_stamp, @@ -2027,8 +1904,12 @@ impl ConsensusExecutionHandler { .transaction_epoch_bound, }; let spec = self.machine.spec(env.number); - let mut ex = - Executive::new(&mut state, &env, self.machine.as_ref(), &spec); + let mut ex = EstimationContext::new( + &mut state, + &env, + self.machine.as_ref(), + &spec, + ); let r = ex.transact_virtual(tx.clone(), request); trace!("Execution result {:?}", r); @@ -2055,14 +1936,7 @@ impl ConsensusExecutionHandler { // that function will update the value after cip107 is enabled // here. if block_number == self.machine.params().transition_numbers.cip107 { - debug!( - "set storage_point_prop to {}", - CIP107_STORAGE_POINT_PROP_INIT - ); - state.set_system_storage( - storage_point_prop().to_vec(), - CIP107_STORAGE_POINT_PROP_INIT.into(), - )?; + initialize_cip107(state)?; } Ok(()) } diff --git a/core/src/consensus/consensus_inner/consensus_new_block_handler.rs b/crates/cfxcore/core/src/consensus/consensus_inner/consensus_new_block_handler.rs similarity index 96% rename from core/src/consensus/consensus_inner/consensus_new_block_handler.rs rename to crates/cfxcore/core/src/consensus/consensus_inner/consensus_new_block_handler.rs index 4145754d95..766a273d00 100644 --- a/core/src/consensus/consensus_inner/consensus_new_block_handler.rs +++ b/crates/cfxcore/core/src/consensus/consensus_inner/consensus_new_block_handler.rs @@ -61,8 +61,7 @@ impl ConsensusNewBlockHandler { data_man: Arc, executor: Arc, statistics: SharedStatistics, notifications: Arc, node_type: NodeType, pos_verifier: Arc, - ) -> Self - { + ) -> Self { let epochs_sender = notifications.epochs_ordered.clone(); let blame_verifier = Mutex::new(BlameVerifier::new(data_man.clone(), notifications)); @@ -475,8 +474,7 @@ impl ConsensusNewBlockHandler { fn check_correct_parent_brutal( inner: &ConsensusGraphInner, me: usize, subtree_weight: &Vec, checking_candidate: Iter, - ) -> bool - { + ) -> bool { let mut valid = true; let parent = inner.arena[me].parent; let force_confirm = inner.arena[me].data.force_confirm; @@ -519,8 +517,7 @@ impl ConsensusNewBlockHandler { fn check_correct_parent( inner: &mut ConsensusGraphInner, me: usize, anticone_barrier: &BitSet, weight_tuple: Option<&Vec>, - ) -> bool - { + ) -> bool { let parent = inner.arena[me].parent; // FIXME: Because now we allow partial invalid blocks as parent, we need // to consider more for block candidates. This may cause a @@ -637,8 +634,7 @@ impl ConsensusNewBlockHandler { fn check_block_full_validity( &self, new: usize, inner: &mut ConsensusGraphInner, adaptive: bool, anticone_barrier: &BitSet, weight_tuple: Option<&Vec>, - ) -> bool - { + ) -> bool { let parent = inner.arena[new].parent; let force_confirm = inner.arena[new].data.force_confirm; @@ -1104,8 +1100,7 @@ impl ConsensusNewBlockHandler { fn activate_block( &self, inner: &mut ConsensusGraphInner, me: usize, meter: &ConfirmationMeter, queue: &mut VecDeque, - ) - { + ) { inner.arena[me].data.activated = true; self.statistics.inc_consensus_graph_activated_block_count(); let mut succ_list = inner.arena[me].children.clone(); @@ -1705,8 +1700,7 @@ impl ConsensusNewBlockHandler { pub fn on_new_block( &self, inner: &mut ConsensusGraphInner, meter: &ConfirmationMeter, hash: &H256, - ) - { + ) { let block_header = self .data_man .block_header_by_hash(hash) @@ -1851,8 +1845,7 @@ impl ConsensusNewBlockHandler { fn persist_block_info( &self, inner: &mut ConsensusGraphInner, me: usize, block_status: BlockStatus, - ) - { + ) { let block_info = LocalBlockInfo::new( block_status, inner.arena[me].data.sequence_number, @@ -2100,8 +2093,7 @@ impl ConsensusNewBlockHandler { fn get_force_compute_index( &self, inner: &mut ConsensusGraphInner, start_pivot_index: usize, end_index: usize, - ) -> usize - { + ) -> usize { let mut force_compute_index = start_pivot_index + 1; let mut epoch_count = 0; for pivot_index in (start_pivot_index + 1..end_index).rev() { @@ -2188,8 +2180,7 @@ impl ConsensusNewBlockHandler { start_compute_epoch_pivot_index: &mut usize, start_pivot_index: usize, end_index: usize, need_set_intermediate_trie_root_merkle: &mut bool, snapshot_epoch_count: u64, - ) -> Option - { + ) -> Option { if !self.conf.inner_conf.use_isolated_db_for_mpt_table { return Some(end_index); } @@ -2219,12 +2210,19 @@ impl ConsensusNewBlockHandler { max_snapshot_epoch_height_has_mpt, ) } else { - (false, HashSet::new(), inner.cur_era_stable_height, None) + (None, HashSet::new(), inner.cur_era_stable_height, None) }; - debug!("latest snapshot epoch height: {}, temp snapshot status: {}, max snapshot epoch height has mpt: {:?}, removed snapshots {:?}", + debug!("latest snapshot epoch height: {}, temp snapshot status: {:?}, max snapshot epoch height has mpt: {:?}, removed snapshots {:?}", latest_snapshot_epoch_height, temp_snapshot_db_existing, max_snapshot_epoch_height_has_mpt, removed_snapshots); + if removed_snapshots.len() == 1 + && removed_snapshots.contains(&NULL_EPOCH) + { + debug!("special case for synced snapshot"); + return Some(end_index); + } + if max_snapshot_epoch_height_has_mpt .is_some_and(|h| h == latest_snapshot_epoch_height) { @@ -2249,71 +2247,68 @@ impl ConsensusNewBlockHandler { latest_snapshot_epoch_height + snapshot_epoch_count * 2; let index = inner.height_to_pivot_index(maximum_height_to_create_next_snapshot); - debug!("start_compute_epoch_pivot_index {}, maximum index for next snapshot {}", - start_compute_epoch_pivot_index, index); - if *start_compute_epoch_pivot_index > index { - warn!("start_compute_epoch_pivot_index is greater than (latest_snapshot_epoch_height + snapshot_epoch_count * 2)"); + warn!("start_compute_epoch_pivot_index is greater than maximum epoch need to compute {}", index); *start_compute_epoch_pivot_index = index; } - let mut max_snapshot_epoch_index_has_mpt = - if max_snapshot_epoch_height_has_mpt.is_some() { - Some(inner.height_to_pivot_index( - max_snapshot_epoch_height_has_mpt.unwrap(), - )) - } else { - None - }; - // Find the closest ear prior to the start_compute_epoch_height let start_compute_epoch_height = inner.arena [inner.pivot_chain[*start_compute_epoch_pivot_index]] .height; + info!( + "current start compute epoch height {}", + start_compute_epoch_height + ); - let recovery_latest_mpt_snapshot = if self - .conf - .inner_conf - .recovery_latest_mpt_snapshot - || start_compute_epoch_height <= latest_snapshot_epoch_height - || (temp_snapshot_db_existing - && latest_snapshot_epoch_height < start_compute_epoch_height - && start_compute_epoch_height - <= latest_snapshot_epoch_height + 2 * snapshot_epoch_count) - { - true - } else { - let mut max_epoch_height = 0; - for pivot_index in (start_pivot_index..end_index) - .step_by(snapshot_epoch_count as usize) + let recovery_latest_mpt_snapshot = + if self.conf.inner_conf.recovery_latest_mpt_snapshot + || start_compute_epoch_height <= latest_snapshot_epoch_height + || (temp_snapshot_db_existing.is_some() + && latest_snapshot_epoch_height + < start_compute_epoch_height + && start_compute_epoch_height + <= latest_snapshot_epoch_height + snapshot_epoch_count) { - let pivot_arena_index = inner.pivot_chain[pivot_index]; - let pivot_hash = inner.arena[pivot_arena_index].hash; - - debug!( - "snapshot pivot_index {} height {} ", - pivot_index, inner.arena[pivot_arena_index].height - ); + true + } else { + let mut max_epoch_height = 0; + for pivot_index in (start_pivot_index..end_index) + .step_by(snapshot_epoch_count as usize) + { + let pivot_arena_index = inner.pivot_chain[pivot_index]; + let pivot_hash = inner.arena[pivot_arena_index].hash; - if removed_snapshots.contains(&pivot_hash) { - max_epoch_height = max( - max_epoch_height, - inner.arena[pivot_arena_index].height, + debug!( + "snapshot pivot_index {} height {} ", + pivot_index, inner.arena[pivot_arena_index].height ); + + if removed_snapshots.contains(&pivot_hash) { + max_epoch_height = max( + max_epoch_height, + inner.arena[pivot_arena_index].height, + ); + } } - } - // snapshots after latest_snapshot_epoch_height is removed - latest_snapshot_epoch_height < max_epoch_height - }; + // snapshots after latest_snapshot_epoch_height is removed + latest_snapshot_epoch_height < max_epoch_height + }; // if the latest_snapshot_epoch_height is greater than // start_compute_epoch_height, the latest MPT snapshot is dirty if recovery_latest_mpt_snapshot { - let era_pivot_epoch_height = + let era_pivot_epoch_height = if start_compute_epoch_height + <= inner.cur_era_stable_height + snapshot_epoch_count + { + debug!("snapshot for cur_era_stable_height must be exist"); + inner.cur_era_stable_height + } else { (start_compute_epoch_height - snapshot_epoch_count - 1) / self.conf.inner_conf.era_epoch_count - * self.conf.inner_conf.era_epoch_count; + * self.conf.inner_conf.era_epoch_count + }; if era_pivot_epoch_height > latest_snapshot_epoch_height { panic!("era_pivot_epoch_height is greater than latest_snapshot_epoch_height, this should not happen"); @@ -2324,10 +2319,6 @@ impl ConsensusNewBlockHandler { start_compute_epoch_height, era_pivot_epoch_height ); - if era_pivot_epoch_height < inner.cur_era_genesis_height { - panic!("unreachable, era_pivot_epoch_height is less than cur_era_genesis_height"); - } - if start_compute_epoch_height <= era_pivot_epoch_height { unreachable!("start_compute_epoch_height {} is smaller than era_pivot_epoch_height {}", start_compute_epoch_height, era_pivot_epoch_height); } else if start_compute_epoch_height @@ -2357,18 +2348,6 @@ impl ConsensusNewBlockHandler { .expect("pivot hash should be exist") }; - let pivot_hash_before_era = if era_pivot_epoch_height == 0 { - None - } else { - Some( - inner - .get_pivot_hash_from_epoch_number( - era_pivot_epoch_height - snapshot_epoch_count, - ) - .expect("pivot hash should be exist"), - ) - }; - let snapshot_db_manager = inner .data_man .storage_manager @@ -2385,31 +2364,55 @@ impl ConsensusNewBlockHandler { .is_some_and(|height| height >= era_pivot_epoch_height) { // mpt snapshot will be created from empty + snapshot_db_manager.recreate_latest_mpt_snapshot().unwrap(); + } else { + let pivot_hash_before_era = if era_pivot_epoch_height == 0 { + None + } else { + Some( + inner + .get_pivot_hash_from_epoch_number( + era_pivot_epoch_height - snapshot_epoch_count, + ) + .expect("pivot hash should be exist"), + ) + }; + + // use ear snapshot replace latest + snapshot_db_manager + .recovery_latest_mpt_snapshot_from_checkpoint( + &era_pivot_hash, + pivot_hash_before_era, + ) + .unwrap(); + } + + max_snapshot_epoch_height_has_mpt.and_then(|v| { + if v >= inner.cur_era_stable_height { + Some(inner.height_to_pivot_index(v)) + } else { + None + } + }) + } else { + if temp_snapshot_db_existing.is_some() + && latest_snapshot_epoch_height + snapshot_epoch_count + < start_compute_epoch_height + && start_compute_epoch_height + <= latest_snapshot_epoch_height + 2 * snapshot_epoch_count + { inner .data_man .storage_manager .get_storage_manager() .get_snapshot_manager() .get_snapshot_db_manager() - .recreate_latest_mpt_snapshot() - .unwrap(); - - return max_snapshot_epoch_index_has_mpt; + .set_reconstruct_snapshot_id(temp_snapshot_db_existing); } - // use ear snapshot replace latest - snapshot_db_manager - .recovery_latest_mpt_snapshot_from_checkpoint( - &era_pivot_hash, - pivot_hash_before_era, - ) - .unwrap(); - } else { debug!("the latest MPT snapshot is valid"); - max_snapshot_epoch_index_has_mpt = Some(end_index); + Some(end_index) } - - max_snapshot_epoch_index_has_mpt } fn set_intermediate_trie_root_merkle( @@ -2417,8 +2420,7 @@ impl ConsensusNewBlockHandler { start_compute_epoch_pivot_index: usize, need_set_intermediate_trie_root_merkle: bool, snapshot_epoch_count: u64, - ) - { + ) { let storage_manager = inner.data_man.storage_manager.get_storage_manager(); if !storage_manager diff --git a/core/src/consensus/consensus_inner/mod.rs b/crates/cfxcore/core/src/consensus/consensus_inner/mod.rs similarity index 99% rename from core/src/consensus/consensus_inner/mod.rs rename to crates/cfxcore/core/src/consensus/consensus_inner/mod.rs index 029e1ae8ab..e44310a311 100644 --- a/core/src/consensus/consensus_inner/mod.rs +++ b/crates/cfxcore/core/src/consensus/consensus_inner/mod.rs @@ -409,8 +409,8 @@ impl Default for ConsensusGraphPivotData { /// 1. the block correctly chooses its parent; /// 2. the block correctly blames the blocks in the intersection of pivot chain /// blocks and all its previous blocks following parent edges. (This is to -/// encourage the node generating the off-pivot block to keep verifying -/// pivot chain blocks.) +/// encourage the node generating the off-pivot block to keep verifying pivot +/// chain blocks.) /// /// To provide proof of state root to light node (or a full node when it tries /// to recover from a checkpoint), the protocol goes through the following @@ -598,8 +598,7 @@ impl ConsensusGraphInner { pos_verifier: Arc, data_man: Arc, inner_conf: ConsensusInnerConfig, cur_era_genesis_block_hash: &H256, cur_era_stable_block_hash: &H256, - ) -> Self - { + ) -> Self { let genesis_block_header = data_man .block_header_by_hash(cur_era_genesis_block_hash) .expect("genesis block header should exist here"); @@ -1066,8 +1065,7 @@ impl ConsensusGraphInner { pub fn find_first_index_with_correct_state_of( &self, pivot_index: usize, blame_bound: Option, min_vote_count: usize, - ) -> Option - { + ) -> Option { // this is the earliest block we need to consider; blocks before `from` // cannot have any information about the state root of `pivot_index` let from = pivot_index + DEFERRED_STATE_EPOCH_COUNT as usize; @@ -1107,8 +1105,7 @@ impl ConsensusGraphInner { fn find_first_with_trusted_blame_starting_from( &self, pivot_index: usize, blame_bound: Option, min_vote_count: usize, - ) -> Option - { + ) -> Option { trace!( "find_first_with_trusted_blame_starting_from pivot_index={:?}", pivot_index @@ -1139,8 +1136,7 @@ impl ConsensusGraphInner { fn compute_blame_ratio( &self, arena_index: usize, blame_bound: Option, min_vote_count: usize, - ) -> f64 - { + ) -> f64 { let blame_bound = if let Some(bound) = blame_bound { bound } else { @@ -1199,8 +1195,7 @@ impl ConsensusGraphInner { pub fn check_mining_adaptive_block( &mut self, parent_arena_index: usize, referee_indices: Vec, difficulty: U256, pos_reference: Option, - ) -> bool - { + ) -> bool { // We first compute anticone barrier for newly mined block let parent_anticone_opt = self.anticone_cache.get(parent_arena_index); let mut anticone; @@ -1325,8 +1320,7 @@ impl ConsensusGraphInner { fn get_best_timer_tick( &self, timer_chain_tuple: &(u64, HashMap, Vec, Vec), - ) -> u64 - { + ) -> u64 { let (fork_at, _, _, c) = timer_chain_tuple; *fork_at + c.len() as u64 } @@ -1334,8 +1328,7 @@ impl ConsensusGraphInner { fn get_timer_tick( &self, me: usize, timer_chain_tuple: &(u64, HashMap, Vec, Vec), - ) -> u64 - { + ) -> u64 { let (fork_at, m, _, _) = timer_chain_tuple; if let Some(t) = m.get(&me) { return *t; @@ -1351,8 +1344,7 @@ impl ConsensusGraphInner { &self, parent_0: usize, subtree_weight: &Vec, timer_chain_tuple: &(u64, HashMap, Vec, Vec), force_confirm: usize, difficulty: i128, - ) -> bool - { + ) -> bool { let mut parent = parent_0; let force_confirm_height = self.arena[force_confirm].height; @@ -1386,8 +1378,7 @@ impl ConsensusGraphInner { weight_tuple: Option<&Vec>, timer_chain_tuple: &(u64, HashMap, Vec, Vec), difficulty: i128, pos_reference: Option, - ) -> bool - { + ) -> bool { let mut parent = parent_0; let force_confirm = self.compute_block_force_confirm(timer_chain_tuple, pos_reference); @@ -1484,8 +1475,7 @@ impl ConsensusGraphInner { &mut self, me: usize, anticone_barrier: &BitSet, weight_tuple: Option<&Vec>, timer_chain_tuple: &(u64, HashMap, Vec, Vec), - ) -> bool - { + ) -> bool { let parent = self.arena[me].parent; assert!(parent != NULL); @@ -1682,8 +1672,7 @@ impl ConsensusGraphInner { &self, timer_chain_tuple: &(u64, HashMap, Vec, Vec), pos_reference: Option, - ) -> usize - { + ) -> usize { let (fork_at, _, extra_lca, tmp_chain) = timer_chain_tuple; let fork_end_index = (*fork_at - self.cur_era_genesis_timer_chain_height) as usize @@ -2515,8 +2504,7 @@ impl ConsensusGraphInner { fn compute_blame_and_state_with_execution_result( &mut self, parent: usize, state_root_hash: H256, receipts_root_hash: H256, logs_bloom_hash: H256, - ) -> Result - { + ) -> Result { let mut cur = parent; let mut blame_cnt: u32 = 0; let mut state_blame_vec = Vec::new(); @@ -2908,10 +2896,10 @@ impl ConsensusGraphInner { } if vote_valid && !self.arena[cur].data.state_valid.expect( - "state_valid for me has been computed in \ + "state_valid for me has been computed in \ wait_and_compute_state_valid_locked by the caller, \ so the precedents should have state_valid", - ) + ) { vote_valid = false; } @@ -3102,8 +3090,7 @@ impl ConsensusGraphInner { fn compute_timer_chain_tuple( &self, parent: usize, referees: &Vec, anticone_opt: Option<&BitSet>, - ) -> (u64, HashMap, Vec, Vec) - { + ) -> (u64, HashMap, Vec, Vec) { let empty_set = BitSet::new(); let anticone = if let Some(a) = anticone_opt { a @@ -3989,8 +3976,7 @@ impl ConsensusGraphInner { pub fn choose_correct_parent( &mut self, parent_arena_index: usize, referee_indices: Vec, pos_reference: Option, - ) -> usize - { + ) -> usize { // We first compute anticone barrier for newly mined block let parent_anticone_opt = self.anticone_cache.get(parent_arena_index); let mut anticone; @@ -4065,8 +4051,7 @@ impl ConsensusGraphInner { &mut self, parent: usize, anticone_barrier: &BitSet, timer_chain_tuple: &(u64, HashMap, Vec, Vec), pos_reference: Option, - ) -> usize - { + ) -> usize { let force_confirm = self.compute_block_force_confirm(timer_chain_tuple, pos_reference); let force_confirm_height = self.arena[force_confirm].height; diff --git a/core/src/consensus/consensus_trait.rs b/crates/cfxcore/core/src/consensus/consensus_trait.rs similarity index 100% rename from core/src/consensus/consensus_trait.rs rename to crates/cfxcore/core/src/consensus/consensus_trait.rs diff --git a/core/src/consensus/debug_recompute.rs b/crates/cfxcore/core/src/consensus/debug_recompute.rs similarity index 98% rename from core/src/consensus/debug_recompute.rs rename to crates/cfxcore/core/src/consensus/debug_recompute.rs index e3568c64e8..b1eb7e15e6 100644 --- a/core/src/consensus/debug_recompute.rs +++ b/crates/cfxcore/core/src/consensus/debug_recompute.rs @@ -6,8 +6,7 @@ pub fn log_debug_epoch_computation( epoch_arena_index: usize, inner: &mut ConsensusGraphInner, executor: &ConsensusExecutor, block_hash: H256, block_height: u64, state_root: &StateRootWithAuxInfo, -) -> ComputeEpochDebugRecord -{ +) -> ComputeEpochDebugRecord { // Parent state root. let parent_arena_index = inner.arena[epoch_arena_index].parent; let parent_epoch_hash = inner.arena[parent_arena_index].hash; @@ -87,8 +86,7 @@ pub fn log_invalid_state_root( deferred: usize, inner: &mut ConsensusGraphInner, executor: &ConsensusExecutor, block_hash: H256, block_height: u64, state_root: &StateRootWithAuxInfo, -) -> std::io::Result<()> -{ +) -> std::io::Result<()> { if let Some(dump_dir) = inner.inner_conf.debug_dump_dir_invalid_state_root.clone() { diff --git a/core/src/consensus/mod.rs b/crates/cfxcore/core/src/consensus/mod.rs similarity index 98% rename from core/src/consensus/mod.rs rename to crates/cfxcore/core/src/consensus/mod.rs index 77f7336adf..c3b035d6bb 100644 --- a/core/src/consensus/mod.rs +++ b/crates/cfxcore/core/src/consensus/mod.rs @@ -28,25 +28,23 @@ use crate::{ }, pos_handler::PosVerifier, }, - executive::{ - internal_contract::build_bloom_and_recover_phantom, EstimateRequest, - ExecutionOutcome, - }, - observer::{ - trace::{ - recover_phantom_traces, ActionType, BlockExecTraces, - LocalizedTrace, TransactionExecTraces, - }, - trace_filter::TraceFilter, - }, pow::{PowComputer, ProofOfWorkConfig}, rpc_errors::{invalid_params, invalid_params_check, Result as RpcResult}, - state::State, statistics::SharedStatistics, transaction_pool::SharedTransactionPool, verification::VerificationConfig, NodeType, Notifications, }; +use cfx_execute_helper::{ + estimation::{EstimateExt, EstimateRequest}, + exec_tracer::{ + recover_phantom_traces, ActionType, BlockExecTraces, LocalizedTrace, + TraceFilter, TransactionExecTraces, + }, + phantom_tx::build_bloom_and_recover_phantom, +}; +use cfx_executor::{executive::ExecutionOutcome, state::State}; + use cfx_internal_common::ChainIdParams; use cfx_parameters::{ consensus::*, @@ -77,7 +75,7 @@ use primitives::{ pos::PosBlockId, receipt::Receipt, BlockHeader, EpochId, EpochNumber, SignedTransaction, TransactionIndex, - TransactionOutcome, + TransactionStatus, }; use rayon::prelude::*; use std::{ @@ -256,8 +254,7 @@ impl ConsensusGraph { execution_conf: ConsensusExecutionConfiguration, verification_config: VerificationConfig, node_type: NodeType, pos_verifier: Arc, - ) -> Self - { + ) -> Self { let inner = Arc::new(RwLock::new(ConsensusGraphInner::with_era_genesis( pow_config, @@ -321,8 +318,7 @@ impl ConsensusGraph { execution_conf: ConsensusExecutionConfiguration, verification_conf: VerificationConfig, node_type: NodeType, pos_verifier: Arc, - ) -> Self - { + ) -> Self { let genesis_hash = data_man.get_cur_consensus_era_genesis_hash(); let stable_hash = data_man.get_cur_consensus_era_stable_hash(); ConsensusGraph::with_era_genesis( @@ -379,8 +375,7 @@ impl ConsensusGraph { &self, inner: &mut ConsensusGraphInner, parent_hash: &H256, referees: &Vec, difficulty: &U256, pos_reference: Option, - ) -> bool - { + ) -> bool { let parent_index = *inner.hash_to_arena_indices.get(parent_hash).expect( "parent_hash is the pivot chain tip,\ @@ -409,8 +404,7 @@ impl ConsensusGraph { pub fn choose_correct_parent( &self, parent_hash: &mut H256, referees: &mut Vec, blame_info: &mut StateBlameInfo, pos_reference: Option, - ) - { + ) { let correct_parent_hash = { if let Some(pos_ref) = &pos_reference { loop { @@ -732,8 +726,7 @@ impl ConsensusGraph { &self, address: AddressWithSpace, block_hash_or_epoch_number: BlockHashOrEpochNumber, rpc_param_name: &str, - ) -> RpcResult - { + ) -> RpcResult { let epoch_number = match block_hash_or_epoch_number { BlockHashOrEpochNumber::BlockHashWithOption { hash, @@ -767,8 +760,7 @@ impl ConsensusGraph { fn filter_block_receipts<'a>( &self, filter: &'a LogFilter, epoch_number: u64, block_hash: H256, mut receipts: Vec, mut tx_hashes: Vec, - ) -> impl Iterator + 'a - { + ) -> impl Iterator + 'a { // sanity check if receipts.len() != tx_hashes.len() { warn!("Block ({}) has different number of receipts ({}) to transactions ({}). Database corrupt?", block_hash, receipts.len(), tx_hashes.len()); @@ -822,8 +814,7 @@ impl ConsensusGraph { fn filter_block<'a>( &self, filter: &'a LogFilter, bloom_possibilities: &'a Vec, epoch: u64, pivot_hash: H256, block_hash: H256, - ) -> Result + 'a, FilterError> - { + ) -> Result + 'a, FilterError> { // special case for genesis (for now, genesis has no logs) if epoch == 0 { return Ok(Either::Left(std::iter::empty())); @@ -886,8 +877,7 @@ impl ConsensusGraph { fn filter_phantom_block<'a>( &self, filter: &'a LogFilter, bloom_possibilities: &'a Vec, epoch: u64, pivot_hash: H256, - ) -> Result + 'a, FilterError> - { + ) -> Result + 'a, FilterError> { // special case for genesis (for now, genesis has no logs) if epoch == 0 { return Ok(Either::Left(std::iter::empty())); @@ -946,8 +936,7 @@ impl ConsensusGraph { fn filter_single_epoch<'a>( &'a self, filter: &'a LogFilter, bloom_possibilities: &'a Vec, epoch: u64, - ) -> Result, FilterError> - { + ) -> Result, FilterError> { // retrieve epoch hashes and pivot hash let mut epoch_hashes = self.inner.read_recursive().block_hashes_by_epoch(epoch)?; @@ -991,8 +980,7 @@ impl ConsensusGraph { fn filter_epoch_batch( &self, filter: &LogFilter, bloom_possibilities: &Vec, epochs: Vec, consistency_check_data: &mut Option<(u64, H256)>, - ) -> Result, FilterError> - { + ) -> Result, FilterError> { // lock so that we have a consistent view during this batch let inner = self.inner.read(); @@ -1030,8 +1018,7 @@ impl ConsensusGraph { pub fn get_log_filter_epoch_range( &self, from_epoch: EpochNumber, to_epoch: EpochNumber, check_range: bool, - ) -> Result, FilterError> - { + ) -> Result, FilterError> { // lock so that we have a consistent view let _inner = self.inner.read_recursive(); @@ -1099,8 +1086,7 @@ impl ConsensusGraph { fn filter_logs_by_epochs( &self, from_epoch: EpochNumber, to_epoch: EpochNumber, filter: &LogFilter, blocks_to_skip: HashSet, check_range: bool, - ) -> Result, FilterError> - { + ) -> Result, FilterError> { let bloom_possibilities = filter.bloom_possibilities(); // we store the last epoch processed and the corresponding pivot hash so @@ -1435,8 +1421,7 @@ impl ConsensusGraph { pub fn call_virtual( &self, tx: &SignedTransaction, epoch: EpochNumber, request: EstimateRequest, - ) -> RpcResult - { + ) -> RpcResult<(ExecutionOutcome, EstimateExt)> { // only allow to call against stated epoch self.validate_stated_epoch(&epoch)?; let (epoch_id, epoch_size) = if let Ok(v) = @@ -1718,8 +1703,7 @@ impl ConsensusGraph { BlockExecTraces, Vec>, )>, - ) -> Result, FilterError> - { + ) -> Result, FilterError> { let mut traces = Vec::new(); for (pivot_hash, block_hash, block_trace, block_txs) in block_traces { if block_txs.len() != block_trace.0.len() { @@ -1747,8 +1731,8 @@ impl ConsensusGraph { { continue; } - for trace in tx_trace - .filter_traces(&filter) + for trace in filter + .filter_traces(tx_trace) .map_err(|e| FilterError::Custom(e))? { if !filter @@ -1810,7 +1794,7 @@ impl ConsensusGraph { }; for receipt in exec_info.block_receipts.receipts.iter() { - if receipt.outcome_status == TransactionOutcome::Skipped { + if receipt.outcome_status == TransactionStatus::Skipped { continue; } @@ -1830,8 +1814,7 @@ impl ConsensusGraph { pub fn get_phantom_block_by_number( &self, block_num: EpochNumber, pivot_assumption: Option, include_traces: bool, - ) -> Result, String> - { + ) -> Result, String> { let hashes = self.get_block_hashes_by_epoch(block_num)?; // special handling for genesis block @@ -1937,7 +1920,7 @@ impl ConsensusGraph { let receipt = &block_receipts[id]; // we do not return non-executed transaction - if receipt.outcome_status == TransactionOutcome::Skipped + if receipt.outcome_status == TransactionStatus::Skipped { continue; } @@ -1969,7 +1952,7 @@ impl ConsensusGraph { // note: failing transactions will not produce any // phantom txs or traces if block_receipts[id].outcome_status - != TransactionOutcome::Success + != TransactionStatus::Success { continue; } @@ -2037,8 +2020,7 @@ impl ConsensusGraph { fn get_state_db_by_epoch_number_with_space( &self, epoch_number: EpochNumber, rpc_param_name: &str, space: Option, - ) -> RpcResult - { + ) -> RpcResult { invalid_params_check( rpc_param_name, self.validate_stated_epoch(&epoch_number), @@ -2211,8 +2193,7 @@ impl ConsensusGraphTrait for ConsensusGraph { let inner = self.inner.read(); if let Some(tx_info) = inner.get_transaction_info(hash) { if let Some(executed) = &tx_info.maybe_executed_extra_info { - if executed.receipt.outcome_status - == TransactionOutcome::Skipped + if executed.receipt.outcome_status == TransactionStatus::Skipped { // A skipped transaction is not visible to clients if // accessed by its hash. diff --git a/core/src/consensus/pastset_cache.rs b/crates/cfxcore/core/src/consensus/pastset_cache.rs similarity index 100% rename from core/src/consensus/pastset_cache.rs rename to crates/cfxcore/core/src/consensus/pastset_cache.rs diff --git a/core/src/consensus/pos_handler.rs b/crates/cfxcore/core/src/consensus/pos_handler.rs similarity index 99% rename from core/src/consensus/pos_handler.rs rename to crates/cfxcore/core/src/consensus/pos_handler.rs index 82a34ebf92..bba4108795 100644 --- a/core/src/consensus/pos_handler.rs +++ b/crates/cfxcore/core/src/consensus/pos_handler.rs @@ -17,6 +17,7 @@ use primitives::pos::{NodeId, PosBlockId}; use storage_interface::{DBReaderForPoW, DbReader}; use crate::{ + genesis_block::GenesisPosState, pos::{ consensus::{ network::{ @@ -32,10 +33,10 @@ use crate::{ pos::{start_pos_consensus, PosDropHandle}, protocol::sync_protocol::HotStuffSynchronizationProtocol, }, - spec::genesis::GenesisPosState, sync::ProtocolConfiguration, ConsensusGraph, }; + use cached_pos_ledger_db::CachedPosLedgerDB; use consensus_types::block::Block; use diem_config::config::SafetyRulesTestConfig; @@ -122,8 +123,7 @@ impl PosHandler { pub fn new( network: Option>, conf: PosConfiguration, enable_height: u64, - ) -> Self - { + ) -> Self { let mut pos = Self { pos: OnceCell::new(), network: Mutex::new(network.clone()), @@ -405,8 +405,7 @@ impl PosHandler { pub fn force_propose( &self, round: U64, parent_block_id: H256, payload: Vec, - ) -> anyhow::Result<()> - { + ) -> anyhow::Result<()> { self.test_command_sender .lock() .as_mut() @@ -511,8 +510,7 @@ impl PosConnection { pub fn new( pos_storage: Arc, consensus_db: Arc, pos_cache_db: Arc, - ) -> Self - { + ) -> Self { Self { pos_storage, consensus_db, diff --git a/core/src/db.rs b/crates/cfxcore/core/src/db.rs similarity index 100% rename from core/src/db.rs rename to crates/cfxcore/core/src/db.rs diff --git a/core/src/error.rs b/crates/cfxcore/core/src/error.rs similarity index 100% rename from core/src/error.rs rename to crates/cfxcore/core/src/error.rs diff --git a/crates/cfxcore/core/src/genesis_block.rs b/crates/cfxcore/core/src/genesis_block.rs new file mode 100644 index 0000000000..810cb590a2 --- /dev/null +++ b/crates/cfxcore/core/src/genesis_block.rs @@ -0,0 +1,556 @@ +// Copyright 2019 Conflux Foundation. All rights reserved. +// Conflux is free software and distributed under GNU General Public License. +// See http://www.gnu.org/licenses/ + +use std::{ + collections::HashMap, + fs::File, + io::{BufRead, BufReader, Read}, + sync::Arc, +}; + +use rustc_hex::FromHex; +use serde::{Deserialize, Serialize}; +use toml::Value; + +use cfx_executor::internal_contract::initialize_internal_contract_accounts; +use cfx_internal_common::debug::ComputeEpochDebugRecord; +use cfx_parameters::{ + consensus::{GENESIS_GAS_LIMIT, ONE_CFX_IN_DRIP}, + consensus_internal::{ + GENESIS_TOKEN_COUNT_IN_CFX, TWO_YEAR_UNLOCK_TOKEN_COUNT_IN_CFX, + }, + genesis::*, + staking::POS_VOTE_PRICE, +}; +use cfx_statedb::StateDb; +use cfx_storage::{StorageManager, StorageManagerTrait}; +use cfx_types::{ + address_util::AddressUtil, Address, AddressSpaceUtil, AddressWithSpace, + Space, H256, U256, +}; +use diem_crypto::{ + bls::BLSPrivateKey, ec_vrf::EcVrfPublicKey, PrivateKey, ValidCryptoMaterial, +}; +use diem_types::validator_config::{ConsensusPublicKey, ConsensusVRFPublicKey}; +use keylib::KeyPair; +use primitives::{ + Action, Block, BlockHeaderBuilder, BlockReceipts, SignedTransaction, +}; +use secret_store::SecretStore; + +use crate::verification::{compute_receipts_root, compute_transaction_root}; +use cfx_executor::{ + executive::{ + contract_address, ExecutionOutcome, ExecutiveContext, TransactOptions, + }, + machine::Machine, + state::{CleanupMode, State}, +}; +use cfx_vm_types::{CreateContractAddress, Env}; +use diem_types::account_address::AccountAddress; +use primitives::transaction::NativeTransaction; + +pub fn default(dev_or_test_mode: bool) -> HashMap { + if !dev_or_test_mode { + return HashMap::new(); + } + let mut accounts: HashMap = HashMap::new(); + // FIXME: Decide the genesis initialization for mainnet. + let balance = U256::from_dec_str("5000000000000000000000000000000000") + .expect("Not overflow"); // 5*10^33 + accounts + .insert(DEV_GENESIS_KEY_PAIR.address().with_native_space(), balance); + accounts.insert( + DEV_GENESIS_KEY_PAIR_2.address().with_native_space(), + balance, + ); + accounts + .insert(DEV_GENESIS_KEY_PAIR.evm_address().with_evm_space(), balance); + accounts.insert( + DEV_GENESIS_KEY_PAIR_2.evm_address().with_evm_space(), + balance, + ); + accounts +} + +pub fn load_secrets_file( + path: &String, secret_store: &SecretStore, +) -> Result, String> { + let file = File::open(path) + .map_err(|e| format!("failed to open file: {:?}", e))?; + let buffered = BufReader::new(file); + + let mut accounts: HashMap = HashMap::new(); + let balance = + U256::from_dec_str("10000000000000000000000").map_err(|e| { + format!( + "failed to parse balance: value = {}, error = {:?}", + "10000000000000000000000", e + ) + })?; + for line in buffered.lines() { + let keypair = + KeyPair::from_secret(line.unwrap().parse().unwrap()).unwrap(); + accounts.insert(keypair.address().with_native_space(), balance.clone()); + secret_store.insert(keypair); + } + Ok(accounts) +} + +/// ` test_net_version` is used to update the genesis author so that after +/// resetting, the chain of the older version will be discarded +pub fn genesis_block( + storage_manager: &Arc, + genesis_accounts: HashMap, + test_net_version: Address, initial_difficulty: U256, machine: Arc, + need_to_execute: bool, genesis_chain_id: Option, + initial_nodes: &Option, +) -> Block { + let mut state = + State::new(StateDb::new(storage_manager.get_state_for_genesis_write())) + .expect("Failed to initialize state"); + + let mut genesis_block_author = test_net_version; + genesis_block_author.set_user_account_type_bits(); + + initialize_internal_contract_accounts( + &mut state, + machine.internal_contracts().initialized_at_genesis(), + ); + trace!("genesis_accounts: {:?}", genesis_accounts); + for (addr, balance) in genesis_accounts { + state + .add_balance(&addr, &balance, CleanupMode::NoEmpty) + .unwrap(); + state.add_total_issued(balance); + if addr.space == Space::Ethereum { + state.add_total_evm_tokens(balance); + } + } + let genesis_account_address = GENESIS_ACCOUNT_ADDRESS.with_native_space(); + + let genesis_token_count = + U256::from(GENESIS_TOKEN_COUNT_IN_CFX) * U256::from(ONE_CFX_IN_DRIP); + state.add_total_issued(genesis_token_count); + let two_year_unlock_token_count = + U256::from(TWO_YEAR_UNLOCK_TOKEN_COUNT_IN_CFX) + * U256::from(ONE_CFX_IN_DRIP); + let four_year_unlock_token_count = + genesis_token_count - two_year_unlock_token_count; + + let genesis_account_init_balance = + U256::from(ONE_CFX_IN_DRIP) * 100 + genesis_token_count; + state + .add_balance( + &genesis_account_address, + &genesis_account_init_balance, + CleanupMode::NoEmpty, + ) + .unwrap(); + + let mut debug_record = Some(ComputeEpochDebugRecord::default()); + + let genesis_chain_id = genesis_chain_id.unwrap_or(0); + let mut genesis_transaction = NativeTransaction::default(); + genesis_transaction.data = GENESIS_TRANSACTION_DATA_STR.as_bytes().into(); + genesis_transaction.action = Action::Call(Default::default()); + genesis_transaction.chain_id = genesis_chain_id; + + let mut create_create2factory_transaction = NativeTransaction::default(); + create_create2factory_transaction.nonce = 0.into(); + create_create2factory_transaction.data = + GENESIS_TRANSACTION_CREATE_CREATE2FACTORY + .from_hex() + .unwrap(); + create_create2factory_transaction.action = Action::Create; + create_create2factory_transaction.chain_id = genesis_chain_id; + create_create2factory_transaction.gas = 300000.into(); + create_create2factory_transaction.gas_price = 1.into(); + create_create2factory_transaction.storage_limit = 512; + + let mut create_genesis_token_manager_two_year_unlock_transaction = + NativeTransaction::default(); + create_genesis_token_manager_two_year_unlock_transaction.nonce = 1.into(); + create_genesis_token_manager_two_year_unlock_transaction.data = + GENESIS_TRANSACTION_CREATE_GENESIS_TOKEN_MANAGER_TWO_YEAR_UNLOCK + .from_hex() + .unwrap(); + create_genesis_token_manager_two_year_unlock_transaction.value = + two_year_unlock_token_count; + create_genesis_token_manager_two_year_unlock_transaction.action = + Action::Create; + create_genesis_token_manager_two_year_unlock_transaction.chain_id = + genesis_chain_id; + create_genesis_token_manager_two_year_unlock_transaction.gas = + 2800000.into(); + create_genesis_token_manager_two_year_unlock_transaction.gas_price = + 1.into(); + create_genesis_token_manager_two_year_unlock_transaction.storage_limit = + 16000; + + let mut create_genesis_token_manager_four_year_unlock_transaction = + NativeTransaction::default(); + create_genesis_token_manager_four_year_unlock_transaction.nonce = 2.into(); + create_genesis_token_manager_four_year_unlock_transaction.data = + GENESIS_TRANSACTION_CREATE_GENESIS_TOKEN_MANAGER_FOUR_YEAR_UNLOCK + .from_hex() + .unwrap(); + create_genesis_token_manager_four_year_unlock_transaction.value = + four_year_unlock_token_count; + create_genesis_token_manager_four_year_unlock_transaction.action = + Action::Create; + create_genesis_token_manager_four_year_unlock_transaction.chain_id = + genesis_chain_id; + create_genesis_token_manager_four_year_unlock_transaction.gas = + 5000000.into(); + create_genesis_token_manager_four_year_unlock_transaction.gas_price = + 1.into(); + create_genesis_token_manager_four_year_unlock_transaction.storage_limit = + 32000; + + let mut create_genesis_investor_fund_transaction = + NativeTransaction::default(); + create_genesis_investor_fund_transaction.nonce = 3.into(); + create_genesis_investor_fund_transaction.data = + GENESIS_TRANSACTION_CREATE_FUND_POOL.from_hex().unwrap(); + create_genesis_investor_fund_transaction.action = Action::Create; + create_genesis_investor_fund_transaction.chain_id = genesis_chain_id; + create_genesis_investor_fund_transaction.gas = 400000.into(); + create_genesis_investor_fund_transaction.gas_price = 1.into(); + create_genesis_investor_fund_transaction.storage_limit = 1000; + + let mut create_genesis_team_fund_transaction = NativeTransaction::default(); + create_genesis_team_fund_transaction.nonce = 4.into(); + create_genesis_team_fund_transaction.data = + GENESIS_TRANSACTION_CREATE_FUND_POOL.from_hex().unwrap(); + create_genesis_team_fund_transaction.action = Action::Create; + create_genesis_team_fund_transaction.chain_id = genesis_chain_id; + create_genesis_team_fund_transaction.gas = 400000.into(); + create_genesis_team_fund_transaction.gas_price = 1.into(); + create_genesis_team_fund_transaction.storage_limit = 1000; + + let mut create_genesis_eco_fund_transaction = NativeTransaction::default(); + create_genesis_eco_fund_transaction.nonce = 5.into(); + create_genesis_eco_fund_transaction.data = + GENESIS_TRANSACTION_CREATE_FUND_POOL.from_hex().unwrap(); + create_genesis_eco_fund_transaction.action = Action::Create; + create_genesis_eco_fund_transaction.chain_id = genesis_chain_id; + create_genesis_eco_fund_transaction.gas = 400000.into(); + create_genesis_eco_fund_transaction.gas_price = 1.into(); + create_genesis_eco_fund_transaction.storage_limit = 1000; + + let mut create_genesis_community_fund_transaction = + NativeTransaction::default(); + create_genesis_community_fund_transaction.nonce = 6.into(); + create_genesis_community_fund_transaction.data = + GENESIS_TRANSACTION_CREATE_FUND_POOL.from_hex().unwrap(); + create_genesis_community_fund_transaction.action = Action::Create; + create_genesis_community_fund_transaction.chain_id = genesis_chain_id; + create_genesis_community_fund_transaction.gas = 400000.into(); + create_genesis_community_fund_transaction.gas_price = 1.into(); + create_genesis_community_fund_transaction.storage_limit = 1000; + + let genesis_transactions = vec![ + Arc::new(genesis_transaction.fake_sign(Default::default())), + Arc::new( + create_create2factory_transaction + .fake_sign(genesis_account_address), + ), + Arc::new( + create_genesis_token_manager_two_year_unlock_transaction + .fake_sign(genesis_account_address), + ), + Arc::new( + create_genesis_token_manager_four_year_unlock_transaction + .fake_sign(genesis_account_address), + ), + Arc::new( + create_genesis_investor_fund_transaction + .fake_sign(genesis_account_address), + ), + Arc::new( + create_genesis_team_fund_transaction + .fake_sign(genesis_account_address), + ), + Arc::new( + create_genesis_eco_fund_transaction + .fake_sign(genesis_account_address), + ), + Arc::new( + create_genesis_community_fund_transaction + .fake_sign(genesis_account_address), + ), + ]; + + if need_to_execute { + const CREATE2FACTORY_TX_INDEX: usize = 1; + /* + const TWO_YEAR_UNLOCK_TX_INDEX: usize = 2; + const FOUR_YEAR_UNLOCK_TX_INDEX: usize = 3; + const INVESTOR_FUND_TX_INDEX: usize = 4; + const TEAM_FUND_TX_INDEX: usize = 5; + const ECO_FUND_TX_INDEX: usize = 6; + const COMMUNITY_FUND_TX_INDEX: usize = 7; + */ + let contract_name_list = vec![ + "CREATE2FACTORY", + "TWO_YEAR_UNLOCK", + "FOUR_YEAR_UNLOCK", + "INVESTOR_FUND", + "TEAM_FUND", + "ECO_FUND", + "COMMUNITY_FUND", + ]; + + for i in CREATE2FACTORY_TX_INDEX..=contract_name_list.len() { + execute_genesis_transaction( + genesis_transactions[i].as_ref(), + &mut state, + machine.clone(), + ); + + let (contract_address, _) = contract_address( + CreateContractAddress::FromSenderNonceAndCodeHash, + 0, + &genesis_account_address, + &(i - 1).into(), + genesis_transactions[i].as_ref().data(), + ); + + state + .set_admin(&contract_address.address, &Address::zero()) + .expect(""); + info!( + "Genesis {:?} addresses: {:?}", + contract_name_list[i - 1], + contract_address + ); + } + } + + if let Some(initial_nodes) = initial_nodes { + for node in &initial_nodes.initial_nodes { + let stake_balance = U256::from(node.voting_power) * *POS_VOTE_PRICE; + // TODO(lpl): Pass in signed tx so they can be retired. + state + .add_balance( + &node.address.with_native_space(), + &(stake_balance + + U256::from(ONE_CFX_IN_DRIP) * U256::from(20)), + CleanupMode::NoEmpty, + ) + .unwrap(); + state + .deposit(&node.address, &stake_balance, 0, false) + .unwrap(); + let signed_tx = node + .register_tx + .clone() + .fake_sign(node.address.with_native_space()); + execute_genesis_transaction( + &signed_tx, + &mut state, + machine.clone(), + ); + } + } + + state + .genesis_special_remove_account(&genesis_account_address.address) + .expect("Clean account failed"); + + let state_root = state + .compute_state_root_for_genesis( + /* debug_record = */ debug_record.as_mut(), + ) + .unwrap(); + let receipt_root = compute_receipts_root(&vec![Arc::new(BlockReceipts { + receipts: vec![], + block_number: 0, + secondary_reward: U256::zero(), + tx_execution_error_messages: vec![], + })]); + + let mut genesis = Block::new( + BlockHeaderBuilder::new() + .with_deferred_state_root(state_root.aux_info.state_root_hash) + .with_deferred_receipts_root(receipt_root) + .with_gas_limit(GENESIS_GAS_LIMIT.into()) + .with_author(genesis_block_author) + .with_difficulty(initial_difficulty) + .with_transactions_root(compute_transaction_root( + &genesis_transactions, + )) + .build(), + genesis_transactions, + ); + genesis.block_header.compute_hash(); + debug!( + "Initialize genesis_block={:?} hash={:?}", + genesis, + genesis.hash() + ); + + state + .commit( + genesis.block_header.hash(), + /* debug_record = */ debug_record.as_mut(), + ) + .unwrap(); + genesis.block_header.pow_hash = Some(Default::default()); + debug!( + "genesis debug_record {}", + serde_json::to_string(&debug_record).unwrap() + ); + genesis +} + +pub fn register_transaction( + bls_priv_key: BLSPrivateKey, vrf_pub_key: EcVrfPublicKey, power: u64, + genesis_chain_id: u32, legacy: bool, +) -> NativeTransaction { + /// TODO: test this function with new internal contracts. + use bls_signatures::{ + sigma_protocol, PrivateKey as BlsPrivKey, PublicKey as BlsPubKey, + Serialize, + }; + use cfx_parameters::internal_contract_addresses::POS_REGISTER_CONTRACT_ADDRESS; + use rand_08::rngs::OsRng; + use solidity_abi::ABIEncodable; + use tiny_keccak::{Hasher, Keccak}; + + let bls_pub_key = bls_priv_key.public_key(); + let (commit, answer) = + sigma_protocol::prove(bls_priv_key.raw_key(), &mut OsRng, legacy); + + let mut encoded_commit = Vec::::new(); + BlsPubKey::from(commit) + .write_bytes(&mut encoded_commit) + .expect("write to Vec never fails"); + + let mut encoded_answer = Vec::::new(); + BlsPrivKey::from(answer) + .write_bytes(&mut encoded_answer) + .expect("write to Vec never fails"); + + let encoded_bls_pub_key = bls_pub_key.to_bytes(); + + let encoded_vrf_pub_key = vrf_pub_key.to_bytes(); + + let mut hasher = Keccak::v256(); + hasher.update(encoded_bls_pub_key.as_slice()); + hasher.update(encoded_vrf_pub_key.as_slice()); + let mut computed_identifier = H256::default(); + hasher.finalize(computed_identifier.as_bytes_mut()); + + let params = ( + computed_identifier, + power, + encoded_bls_pub_key, + encoded_vrf_pub_key, + [encoded_commit, encoded_answer], + ); + + let mut call_data: Vec = "e335b451".from_hex().unwrap(); + call_data.extend_from_slice(¶ms.abi_encode()); + + let mut tx = NativeTransaction::default(); + tx.nonce = 0.into(); + tx.data = call_data; + tx.value = U256::zero(); + tx.action = Action::Call(POS_REGISTER_CONTRACT_ADDRESS); + tx.chain_id = genesis_chain_id; + tx.gas = 200000.into(); + tx.gas_price = 1.into(); + tx.storage_limit = 16000; + tx +} + +fn execute_genesis_transaction( + transaction: &SignedTransaction, state: &mut State, machine: Arc, +) { + let env = Env::default(); + + let options = TransactOptions::default(); + let r = { + ExecutiveContext::new( + state, + &env, + machine.as_ref(), + &machine.spec(env.number), + ) + .transact(transaction, options) + .unwrap() + }; + + match &r { + ExecutionOutcome::Finished(_executed) => {} + _ => { + panic!("genesis transaction should not fail! err={:?}", r); + } + } +} + +pub fn load_file( + path: &String, address_parser: impl Fn(&str) -> Result, +) -> Result, String> { + let mut content = String::new(); + let mut file = File::open(path) + .map_err(|e| format!("failed to open file: {:?}", e))?; + file.read_to_string(&mut content) + .map_err(|e| format!("failed to read file content: {:?}", e))?; + let account_values = content + .parse::() + .map_err(|e| format!("failed to parse toml file: {:?}", e))?; + + let mut accounts: HashMap = HashMap::new(); + match account_values { + Value::Table(table) => { + for (key, value) in table { + let addr = address_parser(&key).map_err(|e| { + format!( + "failed to parse address: value = {}, error = {:?}", + key, e + ) + })?; + + match value { + Value::String(balance) => { + let balance = U256::from_dec_str(&balance).map_err(|e| format!("failed to parse balance: value = {}, error = {:?}", balance, e))?; + accounts.insert(addr.with_native_space(), balance); + } + _ => { + return Err( + "balance in toml file requires String type".into(), + ); + } + } + } + } + _ => { + return Err(format!( + "invalid root value type {:?} in toml file", + account_values.type_str() + )); + } + } + + Ok(accounts) +} + +#[derive(Serialize, Deserialize, Clone)] +pub struct GenesisPosNodeInfo { + pub address: Address, + pub bls_key: ConsensusPublicKey, + pub vrf_key: ConsensusVRFPublicKey, + pub voting_power: u64, + pub register_tx: NativeTransaction, +} + +#[derive(Serialize, Deserialize)] +pub struct GenesisPosState { + pub initial_nodes: Vec, + pub initial_committee: Vec<(AccountAddress, u64)>, + pub initial_seed: H256, +} diff --git a/core/src/lib.rs b/crates/cfxcore/core/src/lib.rs similarity index 91% rename from core/src/lib.rs rename to crates/cfxcore/core/src/lib.rs index a8c7f21914..63e76d1d2f 100644 --- a/core/src/lib.rs +++ b/crates/cfxcore/core/src/lib.rs @@ -26,7 +26,6 @@ extern crate substrate_bn as bn; pub mod message; pub mod block_data_manager; -mod builtin; pub mod cache_config; pub mod cache_manager; pub mod channel; @@ -34,28 +33,19 @@ pub mod client; pub mod consensus; pub mod db; pub mod error; -mod evm; -pub mod executive; +pub mod genesis_block; pub mod light_protocol; -pub mod machine; pub mod node_type; -pub mod observer; pub mod pos; pub mod pow; pub mod rpc_errors; -pub mod spec; -pub mod state; pub mod state_exposer; +mod state_prefetcher; pub mod statistics; pub mod sync; pub mod transaction_pool; pub mod unique_id; pub mod verification; -pub mod vm; -pub mod vm_factory; - -#[cfg(test)] -pub mod test_helpers; pub use crate::{ block_data_manager::BlockDataManager, diff --git a/core/src/light_protocol/common/ledger_info.rs b/crates/cfxcore/core/src/light_protocol/common/ledger_info.rs similarity index 100% rename from core/src/light_protocol/common/ledger_info.rs rename to crates/cfxcore/core/src/light_protocol/common/ledger_info.rs diff --git a/core/src/light_protocol/common/mod.rs b/crates/cfxcore/core/src/light_protocol/common/mod.rs similarity index 98% rename from core/src/light_protocol/common/mod.rs rename to crates/cfxcore/core/src/light_protocol/common/mod.rs index 4cc13bed27..1599dfc2f7 100644 --- a/core/src/light_protocol/common/mod.rs +++ b/crates/cfxcore/core/src/light_protocol/common/mod.rs @@ -24,8 +24,7 @@ where I: Iterator { pub fn validate_chain_id( ours: &ChainIdParamsOneChainInner, theirs: ChainIdParamsOneChainInner, peer_height: u64, -) -> Result<(), Error> -{ +) -> Result<(), Error> { if !ours.matches(&theirs, peer_height) { let error_kind = ErrorKind::ChainIdMismatch { ours: ours.clone(), diff --git a/core/src/light_protocol/common/peers.rs b/crates/cfxcore/core/src/light_protocol/common/peers.rs similarity index 100% rename from core/src/light_protocol/common/peers.rs rename to crates/cfxcore/core/src/light_protocol/common/peers.rs diff --git a/core/src/light_protocol/config.rs b/crates/cfxcore/core/src/light_protocol/config.rs similarity index 100% rename from core/src/light_protocol/config.rs rename to crates/cfxcore/core/src/light_protocol/config.rs diff --git a/core/src/light_protocol/error.rs b/crates/cfxcore/core/src/light_protocol/error.rs similarity index 100% rename from core/src/light_protocol/error.rs rename to crates/cfxcore/core/src/light_protocol/error.rs diff --git a/core/src/light_protocol/handler/mod.rs b/crates/cfxcore/core/src/light_protocol/handler/mod.rs similarity index 99% rename from core/src/light_protocol/handler/mod.rs rename to crates/cfxcore/core/src/light_protocol/handler/mod.rs index ac78cbfdb0..e8ae4ab726 100644 --- a/core/src/light_protocol/handler/mod.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/mod.rs @@ -123,8 +123,7 @@ impl Handler { consensus: SharedConsensusGraph, graph: Arc, throttling_config_file: Option, notifications: Arc, config: LightNodeConfiguration, - ) -> Self - { + ) -> Self { let peers = Arc::new(Peers::new()); let request_id_allocator = Arc::new(UniqueId::new()); @@ -235,8 +234,7 @@ impl Handler { fn start_witness_worker( notifications: Arc, witnesses: Arc, stopped: Arc, data_man: Arc, - ) -> thread::JoinHandle<()> - { + ) -> thread::JoinHandle<()> { thread::Builder::new() .name("Witness Worker".into()) .spawn(move || { @@ -482,8 +480,7 @@ impl Handler { fn send_status( &self, io: &dyn NetworkContext, peer: &NodeId, peer_protocol_version: ProtocolVersion, - ) -> Result<()> - { + ) -> Result<()> { let msg: Box; if peer_protocol_version == LIGHT_PROTO_V1 { @@ -582,8 +579,7 @@ impl Handler { fn on_status_deprecated( &self, io: &dyn NetworkContext, peer: &NodeId, status: StatusPongDeprecatedV1, - ) -> Result<()> - { + ) -> Result<()> { debug!("on_status (v1) peer={:?} status={:?}", peer, status); self.on_status_v2( @@ -604,8 +600,7 @@ impl Handler { fn on_block_hashes( &self, io: &dyn NetworkContext, _peer: &NodeId, resp: GetBlockHashesResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} block hashes (request id = {})", resp.hashes.len(), @@ -626,8 +621,7 @@ impl Handler { fn on_block_headers( &self, io: &dyn NetworkContext, peer: &NodeId, resp: GetBlockHeadersResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} block headers (request id = {})", resp.headers.len(), @@ -648,8 +642,7 @@ impl Handler { fn on_block_txs( &self, io: &dyn NetworkContext, peer: &NodeId, resp: GetBlockTxsResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} block txs (request id = {})", resp.block_txs.len(), @@ -712,8 +705,7 @@ impl Handler { fn on_receipts( &self, io: &dyn NetworkContext, peer: &NodeId, resp: GetReceiptsResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} receipts (request id = {})", resp.receipts.len(), @@ -734,8 +726,7 @@ impl Handler { fn on_state_entries( &self, io: &dyn NetworkContext, peer: &NodeId, resp: GetStateEntriesResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} state entries (request id = {})", resp.entries.len(), @@ -756,8 +747,7 @@ impl Handler { fn on_state_roots( &self, io: &dyn NetworkContext, peer: &NodeId, resp: GetStateRootsResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} state roots (request id = {})", resp.state_roots.len(), @@ -778,8 +768,7 @@ impl Handler { fn on_storage_roots( &self, io: &dyn NetworkContext, peer: &NodeId, resp: GetStorageRootsResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} storage roots (request id = {})", resp.roots.len(), @@ -834,8 +823,7 @@ impl Handler { fn on_witness_info( &self, io: &dyn NetworkContext, peer: &NodeId, resp: GetWitnessInfoResponse, - ) -> Result<()> - { + ) -> Result<()> { debug!( "received {} witnesses (request id = {})", resp.infos.len(), @@ -999,8 +987,7 @@ impl NetworkProtocolHandler for Handler { &self, io: &dyn NetworkContext, node_id: &NodeId, peer_protocol_version: ProtocolVersion, _pos_public_key: Option<(ConsensusPublicKey, ConsensusVRFPublicKey)>, - ) - { + ) { debug!("on_peer_connected: peer={:?}", node_id); match self.send_status(io, node_id, peer_protocol_version) { diff --git a/core/src/light_protocol/handler/sync/block_txs.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/block_txs.rs similarity index 99% rename from core/src/light_protocol/handler/sync/block_txs.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/block_txs.rs index d41ef02a96..97bdb272b7 100644 --- a/core/src/light_protocol/handler/sync/block_txs.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/block_txs.rs @@ -65,8 +65,7 @@ impl BlockTxs { pub fn new( consensus: SharedConsensusGraph, peers: Arc>, request_id_allocator: Arc, txs: Arc, - ) -> Self - { + ) -> Self { let ledger = LedgerInfo::new(consensus.clone()); let sync_manager = SyncManager::new(peers.clone(), msgid::GET_BLOCK_TXS); @@ -119,8 +118,7 @@ impl BlockTxs { pub fn receive( &self, peer: &NodeId, id: RequestId, block_txs: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for BlockTxsWithHash { hash, block_txs } in block_txs { trace!("Validating block_txs {:?} with hash {}", block_txs, hash); diff --git a/core/src/light_protocol/handler/sync/blooms.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/blooms.rs similarity index 99% rename from core/src/light_protocol/handler/sync/blooms.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/blooms.rs index 8a2dccb3ca..e756954d72 100644 --- a/core/src/light_protocol/handler/sync/blooms.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/blooms.rs @@ -61,8 +61,7 @@ impl Blooms { pub fn new( peers: Arc>, request_id_allocator: Arc, witnesses: Arc, - ) -> Self - { + ) -> Self { let sync_manager = SyncManager::new(peers.clone(), msgid::GET_BLOOMS); let cache = LruCache::with_expiry_duration(*CACHE_TIMEOUT); @@ -114,8 +113,7 @@ impl Blooms { pub fn receive( &self, peer: &NodeId, id: RequestId, blooms: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for BloomWithEpoch { epoch, bloom } in blooms { trace!("Validating bloom {:?} with epoch {}", bloom, epoch); diff --git a/core/src/light_protocol/handler/sync/common/future_item.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/common/future_item.rs similarity index 100% rename from core/src/light_protocol/handler/sync/common/future_item.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/common/future_item.rs diff --git a/core/src/light_protocol/handler/sync/common/ledger_proof.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/common/ledger_proof.rs similarity index 100% rename from core/src/light_protocol/handler/sync/common/ledger_proof.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/common/ledger_proof.rs diff --git a/core/src/light_protocol/handler/sync/common/missing_item.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/common/missing_item.rs similarity index 100% rename from core/src/light_protocol/handler/sync/common/missing_item.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/common/missing_item.rs diff --git a/core/src/light_protocol/handler/sync/common/mod.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/common/mod.rs similarity index 100% rename from core/src/light_protocol/handler/sync/common/mod.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/common/mod.rs diff --git a/core/src/light_protocol/handler/sync/common/priority_queue.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/common/priority_queue.rs similarity index 100% rename from core/src/light_protocol/handler/sync/common/priority_queue.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/common/priority_queue.rs diff --git a/core/src/light_protocol/handler/sync/common/sync_manager.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/common/sync_manager.rs similarity index 99% rename from core/src/light_protocol/handler/sync/common/sync_manager.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/common/sync_manager.rs index 0bd554779b..867ebcc7a4 100644 --- a/core/src/light_protocol/handler/sync/common/sync_manager.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/common/sync_manager.rs @@ -154,8 +154,7 @@ where pub fn sync( &self, max_in_flight: usize, batch_size: usize, request: impl Fn(&NodeId, Vec) -> Result, Error>, - ) - { + ) { let _guard = match self.sync_lock.try_lock() { None => return, Some(g) => g, diff --git a/core/src/light_protocol/handler/sync/epochs.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/epochs.rs similarity index 99% rename from core/src/light_protocol/handler/sync/epochs.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/epochs.rs index 6608ba40a5..38ef7888ec 100644 --- a/core/src/light_protocol/handler/sync/epochs.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/epochs.rs @@ -97,8 +97,7 @@ impl Epochs { consensus: SharedConsensusGraph, headers: Arc, peers: Arc>, request_id_allocator: Arc, config: LightNodeConfiguration, - ) -> Self - { + ) -> Self { let in_flight = RwLock::new(HashMap::new()); let latest = AtomicU64::new(0); let received_count = AtomicU64::new(0); diff --git a/core/src/light_protocol/handler/sync/headers.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/headers.rs similarity index 99% rename from core/src/light_protocol/handler/sync/headers.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/headers.rs index 5516921a2b..0b3e22a311 100644 --- a/core/src/light_protocol/handler/sync/headers.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/headers.rs @@ -116,8 +116,7 @@ impl Headers { pub fn new( graph: Arc, peers: Arc>, request_id_allocator: Arc, config: LightNodeConfiguration, - ) -> Self - { + ) -> Self { let duplicate_count = AtomicU64::new(0); let inserted_count = AtomicU64::new(0); let sync_manager = @@ -191,8 +190,7 @@ impl Headers { pub fn receive( &self, peer: &NodeId, id: RequestId, headers: impl Iterator, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { let mut missing = HashSet::new(); let mut has_invalid_header = false; diff --git a/core/src/light_protocol/handler/sync/mod.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/mod.rs similarity index 100% rename from core/src/light_protocol/handler/sync/mod.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/mod.rs diff --git a/core/src/light_protocol/handler/sync/receipts.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/receipts.rs similarity index 99% rename from core/src/light_protocol/handler/sync/receipts.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/receipts.rs index 7c746605b2..cb16a869ae 100644 --- a/core/src/light_protocol/handler/sync/receipts.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/receipts.rs @@ -60,8 +60,7 @@ impl Receipts { pub fn new( peers: Arc>, request_id_allocator: Arc, witnesses: Arc, - ) -> Self - { + ) -> Self { let sync_manager = SyncManager::new(peers.clone(), msgid::GET_RECEIPTS); let cache = LruCache::with_expiry_duration(*CACHE_TIMEOUT); @@ -115,8 +114,7 @@ impl Receipts { pub fn receive( &self, peer: &NodeId, id: RequestId, receipts: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for ReceiptsWithEpoch { epoch, epoch_receipts, diff --git a/core/src/light_protocol/handler/sync/state_entries.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/state_entries.rs similarity index 99% rename from core/src/light_protocol/handler/sync/state_entries.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/state_entries.rs index fa635cb4dd..21f31812e7 100644 --- a/core/src/light_protocol/handler/sync/state_entries.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/state_entries.rs @@ -63,8 +63,7 @@ impl StateEntries { pub fn new( peers: Arc>, state_roots: Arc, request_id_allocator: Arc, - ) -> Self - { + ) -> Self { let sync_manager = SyncManager::new(peers.clone(), msgid::GET_STATE_ENTRIES); @@ -119,8 +118,7 @@ impl StateEntries { pub fn receive( &self, peer: &NodeId, id: RequestId, entries: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for StateEntryWithKey { key, entry, proof } in entries { trace!( "Validating state entry {:?} with key {:?} and proof {:?}", @@ -220,8 +218,7 @@ impl StateEntries { fn validate_state_entry( &self, epoch: u64, key: &Vec, value: &Option>, proof: StateEntryProof, - ) -> Result<()> - { + ) -> Result<()> { // validate state root let state_root = proof.state_root; diff --git a/core/src/light_protocol/handler/sync/state_roots.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/state_roots.rs similarity index 99% rename from core/src/light_protocol/handler/sync/state_roots.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/state_roots.rs index d07dab493c..015d8bfe46 100644 --- a/core/src/light_protocol/handler/sync/state_roots.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/state_roots.rs @@ -61,8 +61,7 @@ impl StateRoots { pub fn new( peers: Arc>, request_id_allocator: Arc, snapshot_epoch_count: u64, witnesses: Arc, - ) -> Self - { + ) -> Self { let sync_manager = SyncManager::new(peers.clone(), msgid::GET_STATE_ROOTS); @@ -126,8 +125,7 @@ impl StateRoots { pub fn receive( &self, peer: &NodeId, id: RequestId, state_roots: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for StateRootWithEpoch { epoch, state_root } in state_roots { trace!( "Validating state root {:?} with epoch {}", @@ -245,8 +243,7 @@ impl StateRoots { pub fn validate_prev_snapshot_state_root( &self, current_epoch: u64, maybe_prev_snapshot_state_root: &Option, - ) -> Result<()> - { + ) -> Result<()> { let snapshot_epoch_count = self.snapshot_epoch_count; match maybe_prev_snapshot_state_root { diff --git a/core/src/light_protocol/handler/sync/storage_roots.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/storage_roots.rs similarity index 98% rename from core/src/light_protocol/handler/sync/storage_roots.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/storage_roots.rs index 29dbe76f03..a0531b51f3 100644 --- a/core/src/light_protocol/handler/sync/storage_roots.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/storage_roots.rs @@ -62,8 +62,7 @@ impl StorageRoots { pub fn new( peers: Arc>, state_roots: Arc, request_id_allocator: Arc, - ) -> Self - { + ) -> Self { let sync_manager = SyncManager::new(peers.clone(), msgid::GET_STORAGE_ROOTS); @@ -118,8 +117,7 @@ impl StorageRoots { pub fn receive( &self, peer: &NodeId, id: RequestId, entries: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for StorageRootWithKey { key, root, proof } in entries { trace!("Validating storage root {:?} with key {:?}", root, key); @@ -181,8 +179,7 @@ impl StorageRoots { fn send_request( &self, io: &dyn NetworkContext, peer: &NodeId, keys: Vec, - ) -> Result> - { + ) -> Result> { if keys.is_empty() { return Ok(None); } @@ -216,8 +213,7 @@ impl StorageRoots { fn validate_storage_root( &self, epoch: u64, address: H160, storage_root: &StorageRoot, proof: StorageRootProof, - ) -> Result<()> - { + ) -> Result<()> { // validate state root let state_root = proof.state_root; diff --git a/core/src/light_protocol/handler/sync/tx_infos.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/tx_infos.rs similarity index 98% rename from core/src/light_protocol/handler/sync/tx_infos.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/tx_infos.rs index a4c43b65b4..5598d8f2aa 100644 --- a/core/src/light_protocol/handler/sync/tx_infos.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/tx_infos.rs @@ -31,7 +31,7 @@ use lru_time_cache::LruCache; use network::{node_table::NodeId, NetworkContext}; use parking_lot::RwLock; use primitives::{ - Receipt, SignedTransaction, TransactionIndex, TransactionOutcome, + Receipt, SignedTransaction, TransactionIndex, TransactionStatus, }; use std::{future::Future, sync::Arc}; @@ -77,8 +77,7 @@ impl TxInfos { pub fn new( consensus: SharedConsensusGraph, peers: Arc>, request_id_allocator: Arc, witnesses: Arc, - ) -> Self - { + ) -> Self { let ledger = LedgerInfo::new(consensus.clone()); let sync_manager = SyncManager::new(peers.clone(), msgid::GET_TX_INFOS); @@ -133,8 +132,7 @@ impl TxInfos { pub fn receive( &self, peer: &NodeId, id: RequestId, infos: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for info in infos { trace!("Validating tx_info {:?}", info); @@ -217,8 +215,8 @@ impl TxInfos { // only executed instances of the transaction are acceptable; // receipts belonging to non-executed instances should not be sent - if receipt.outcome_status != TransactionOutcome::Success - && receipt.outcome_status != TransactionOutcome::Failure + if receipt.outcome_status != TransactionStatus::Success + && receipt.outcome_status != TransactionStatus::Failure { bail!(ErrorKind::InvalidTxInfo { reason: format!( diff --git a/core/src/light_protocol/handler/sync/txs.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/txs.rs similarity index 99% rename from core/src/light_protocol/handler/sync/txs.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/txs.rs index 3f44fff5b0..4db7ea149e 100644 --- a/core/src/light_protocol/handler/sync/txs.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/txs.rs @@ -104,8 +104,7 @@ impl Txs { pub fn receive( &self, peer: &NodeId, id: RequestId, txs: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for tx in txs { let hash = tx.hash(); trace!("Validating tx {:?}", hash); diff --git a/core/src/light_protocol/handler/sync/witnesses.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/witnesses.rs similarity index 99% rename from core/src/light_protocol/handler/sync/witnesses.rs rename to crates/cfxcore/core/src/light_protocol/handler/sync/witnesses.rs index 789df4aa04..7f36cbf239 100644 --- a/core/src/light_protocol/handler/sync/witnesses.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/witnesses.rs @@ -83,8 +83,7 @@ impl Witnesses { pub fn new( consensus: SharedConsensusGraph, peers: Arc>, request_id_allocator: Arc, - ) -> Self - { + ) -> Self { let data_man = consensus.get_data_manager().clone(); let height_of_latest_verified_header = RwLock::new(0); let in_flight = RwLock::new(HashSet::new()); @@ -218,8 +217,7 @@ impl Witnesses { pub fn receive( &self, peer: &NodeId, id: RequestId, witnesses: impl Iterator, - ) -> Result<()> - { + ) -> Result<()> { for item in witnesses { trace!("Validating witness info {:?}", item); diff --git a/core/src/light_protocol/message/message.rs b/crates/cfxcore/core/src/light_protocol/message/message.rs similarity index 100% rename from core/src/light_protocol/message/message.rs rename to crates/cfxcore/core/src/light_protocol/message/message.rs diff --git a/core/src/light_protocol/message/mod.rs b/crates/cfxcore/core/src/light_protocol/message/mod.rs similarity index 100% rename from core/src/light_protocol/message/mod.rs rename to crates/cfxcore/core/src/light_protocol/message/mod.rs diff --git a/core/src/light_protocol/message/protocol.rs b/crates/cfxcore/core/src/light_protocol/message/protocol.rs similarity index 100% rename from core/src/light_protocol/message/protocol.rs rename to crates/cfxcore/core/src/light_protocol/message/protocol.rs diff --git a/core/src/light_protocol/mod.rs b/crates/cfxcore/core/src/light_protocol/mod.rs similarity index 100% rename from core/src/light_protocol/mod.rs rename to crates/cfxcore/core/src/light_protocol/mod.rs diff --git a/core/src/light_protocol/provider.rs b/crates/cfxcore/core/src/light_protocol/provider.rs similarity index 99% rename from core/src/light_protocol/provider.rs rename to crates/cfxcore/core/src/light_protocol/provider.rs index bed8ff099c..0b62e5eda6 100644 --- a/core/src/light_protocol/provider.rs +++ b/crates/cfxcore/core/src/light_protocol/provider.rs @@ -102,8 +102,7 @@ impl Provider { consensus: SharedConsensusGraph, graph: Arc, network: Weak, tx_pool: Arc, throttling_config_file: Option, node_type: NodeType, - ) -> Self - { + ) -> Self { let ledger = LedgerInfo::new(consensus.clone()); let peers = Peers::new(); @@ -460,8 +459,7 @@ impl Provider { fn on_status_deprecated( &self, io: &dyn NetworkContext, peer: &NodeId, status: StatusPingDeprecatedV1, - ) -> Result<()> - { + ) -> Result<()> { debug!("on_status (v1) peer={:?} status={:?}", peer, status); self.on_status_v2( @@ -571,8 +569,7 @@ impl Provider { fn on_get_block_hashes_by_epoch( &self, io: &dyn NetworkContext, peer: &NodeId, req: GetBlockHashesByEpoch, - ) -> Result<()> - { + ) -> Result<()> { debug!("on_get_block_hashes_by_epoch req={:?}", req); self.throttle(peer, &req)?; let request_id = req.request_id; @@ -917,8 +914,7 @@ impl Provider { fn broadcast( &self, io: &dyn NetworkContext, mut peers: Vec, msg: &dyn Message, - ) -> Result<()> - { + ) -> Result<()> { debug!("broadcast peers={:?}", peers); let throttle_ratio = THROTTLING_SERVICE.read().get_throttling_ratio(); @@ -1053,8 +1049,7 @@ impl NetworkProtocolHandler for Provider { &self, _io: &dyn NetworkContext, node_id: &NodeId, peer_protocol_version: ProtocolVersion, _pos_public_key: Option<(ConsensusPublicKey, ConsensusVRFPublicKey)>, - ) - { + ) { debug!( "on_peer_connected: peer={:?} version={}", node_id, peer_protocol_version diff --git a/core/src/light_protocol/query_service.rs b/crates/cfxcore/core/src/light_protocol/query_service.rs similarity index 99% rename from core/src/light_protocol/query_service.rs rename to crates/cfxcore/core/src/light_protocol/query_service.rs index 4552dbba99..6b0f384d1f 100644 --- a/core/src/light_protocol/query_service.rs +++ b/crates/cfxcore/core/src/light_protocol/query_service.rs @@ -12,11 +12,11 @@ use crate::{ LIGHT_PROTOCOL_ID, LIGHT_PROTOCOL_VERSION, }, rpc_errors::{account_result_to_rpc_result, Error as RpcError}, - state::COMMISSION_PRIVILEGE_SPECIAL_KEY, sync::SynchronizationGraph, ConsensusGraph, Notifications, }; use cfx_addr::Network; +use cfx_executor::state::COMMISSION_PRIVILEGE_SPECIAL_KEY; use cfx_parameters::{ consensus::DEFERRED_STATE_EPOCH_COUNT, internal_contract_addresses::SPONSOR_WHITELIST_CONTROL_CONTRACT_ADDRESS, @@ -63,8 +63,7 @@ pub struct TxInfo { async fn with_timeout( d: Duration, msg: String, fut: impl Future> + Send + Sync, -) -> Result -{ +) -> Result { // convert `fut` into futures@0.1 let fut = fut.unit_error().boxed().compat(); @@ -102,8 +101,7 @@ impl QueryService { consensus: SharedConsensusGraph, graph: Arc, network: Arc, throttling_config_file: Option, notifications: Arc, config: LightNodeConfiguration, - ) -> Self - { + ) -> Self { let handler = Arc::new(LightHandler::new( consensus.clone(), graph, @@ -309,8 +307,8 @@ impl QueryService { // retrieve blocks in batches let mut stream = stream::iter(hashes) - .map(|h| { - async move { self.retrieve_block(h).await.map(move |b| (h, b)) } + .map(|h| async move { + self.retrieve_block(h).await.map(move |b| (h, b)) }) .buffered(GAS_PRICE_BATCH_SIZE); @@ -699,8 +697,7 @@ impl QueryService { epoch: u64, block_hash: H256, transaction_index: usize, num_logs_remaining: &mut usize, mut logs: Vec, filter: LogFilter, - ) -> impl Iterator - { + ) -> impl Iterator { let num_logs = logs.len(); let log_base_index = *num_logs_remaining; @@ -727,8 +724,7 @@ impl QueryService { fn filter_block_receipts( epoch: u64, hash: H256, block_receipts: BlockReceipts, filter: LogFilter, - ) -> impl Iterator - { + ) -> impl Iterator { let mut receipts = block_receipts.receipts; // number of receipts in this block let num_receipts = receipts.len(); diff --git a/core/src/message.rs b/crates/cfxcore/core/src/message.rs similarity index 99% rename from core/src/message.rs rename to crates/cfxcore/core/src/message.rs index 3c3a749aec..d095a5a929 100644 --- a/core/src/message.rs +++ b/crates/cfxcore/core/src/message.rs @@ -87,8 +87,7 @@ pub trait Message: fn send_with_throttling( &self, io: &dyn NetworkContext, node_id: &NodeId, throttling_disabled: bool, - ) -> Result<(), NetworkError> - { + ) -> Result<(), NetworkError> { if !throttling_disabled && self.is_size_sensitive() { if let Err(e) = THROTTLING_SERVICE.read().check_throttling() { debug!("Throttling failure: {:?}", e); diff --git a/core/src/node_type.rs b/crates/cfxcore/core/src/node_type.rs similarity index 100% rename from core/src/node_type.rs rename to crates/cfxcore/core/src/node_type.rs diff --git a/core/src/pos/common/bounded-executor/Cargo.toml b/crates/cfxcore/core/src/pos/common/bounded-executor/Cargo.toml similarity index 100% rename from core/src/pos/common/bounded-executor/Cargo.toml rename to crates/cfxcore/core/src/pos/common/bounded-executor/Cargo.toml diff --git a/core/src/pos/common/bounded-executor/src/lib.rs b/crates/cfxcore/core/src/pos/common/bounded-executor/src/lib.rs similarity index 100% rename from core/src/pos/common/bounded-executor/src/lib.rs rename to crates/cfxcore/core/src/pos/common/bounded-executor/src/lib.rs diff --git a/core/src/pos/common/channel/Cargo.toml b/crates/cfxcore/core/src/pos/common/channel/Cargo.toml similarity index 92% rename from core/src/pos/common/channel/Cargo.toml rename to crates/cfxcore/core/src/pos/common/channel/Cargo.toml index e915ca26ae..d62348742a 100644 --- a/core/src/pos/common/channel/Cargo.toml +++ b/crates/cfxcore/core/src/pos/common/channel/Cargo.toml @@ -16,5 +16,5 @@ diem-metrics = { path = "../metrics" } diem-infallible = { path = "../infallible" } [dev-dependencies] -diem-types = { path = "../../types" } +diem-types = { path = "../../types" } tokio = { version = "1.3.0", features = ["full"] } diff --git a/core/src/pos/common/channel/many-keys-stress-test/Cargo.toml b/crates/cfxcore/core/src/pos/common/channel/many-keys-stress-test/Cargo.toml similarity index 100% rename from core/src/pos/common/channel/many-keys-stress-test/Cargo.toml rename to crates/cfxcore/core/src/pos/common/channel/many-keys-stress-test/Cargo.toml diff --git a/core/src/pos/common/channel/many-keys-stress-test/src/main.rs b/crates/cfxcore/core/src/pos/common/channel/many-keys-stress-test/src/main.rs similarity index 100% rename from core/src/pos/common/channel/many-keys-stress-test/src/main.rs rename to crates/cfxcore/core/src/pos/common/channel/many-keys-stress-test/src/main.rs diff --git a/core/src/pos/common/channel/src/diem_channel.rs b/crates/cfxcore/core/src/pos/common/channel/src/diem_channel.rs similarity index 99% rename from core/src/pos/common/channel/src/diem_channel.rs rename to crates/cfxcore/core/src/pos/common/channel/src/diem_channel.rs index 67762bb34c..952e5d4abc 100644 --- a/core/src/pos/common/channel/src/diem_channel.rs +++ b/crates/cfxcore/core/src/pos/common/channel/src/diem_channel.rs @@ -100,8 +100,7 @@ impl Sender { pub fn push_with_feedback( &self, key: K, message: M, status_ch: Option>>, - ) -> Result<()> - { + ) -> Result<()> { let mut shared_state = self.shared_state.lock(); ensure!(!shared_state.receiver_dropped, "Channel is closed"); debug_assert!(shared_state.num_senders > 0); @@ -210,8 +209,7 @@ impl FusedStream for Receiver { pub fn new( queue_style: QueueStyle, max_queue_size_per_key: usize, counters: Option<&'static IntCounterVec>, -) -> (Sender, Receiver) -{ +) -> (Sender, Receiver) { let max_queue_size_per_key = NonZeroUsize!( max_queue_size_per_key, "diem_channel cannot be of size 0" diff --git a/core/src/pos/common/channel/src/diem_channel_test.rs b/crates/cfxcore/core/src/pos/common/channel/src/diem_channel_test.rs similarity index 99% rename from core/src/pos/common/channel/src/diem_channel_test.rs rename to crates/cfxcore/core/src/pos/common/channel/src/diem_channel_test.rs index 5b7b9bc27b..9406ec78f0 100644 --- a/core/src/pos/common/channel/src/diem_channel_test.rs +++ b/crates/cfxcore/core/src/pos/common/channel/src/diem_channel_test.rs @@ -98,8 +98,7 @@ fn test_sender_clone() { fn test_multiple_validators_helper( queue_style: QueueStyle, num_messages_per_validator: usize, expected_last_message: usize, -) -{ +) { let (sender, mut receiver) = diem_channel::new(queue_style, 1, None); let num_validators = 128; for message in 0..num_messages_per_validator { diff --git a/core/src/pos/common/channel/src/lib.rs b/crates/cfxcore/core/src/pos/common/channel/src/lib.rs similarity index 100% rename from core/src/pos/common/channel/src/lib.rs rename to crates/cfxcore/core/src/pos/common/channel/src/lib.rs diff --git a/core/src/pos/common/channel/src/message_queues.rs b/crates/cfxcore/core/src/pos/common/channel/src/message_queues.rs similarity index 99% rename from core/src/pos/common/channel/src/message_queues.rs rename to crates/cfxcore/core/src/pos/common/channel/src/message_queues.rs index 5deeaeddbf..ca5e195e3e 100644 --- a/core/src/pos/common/channel/src/message_queues.rs +++ b/crates/cfxcore/core/src/pos/common/channel/src/message_queues.rs @@ -77,8 +77,7 @@ impl PerKeyQueue { pub(crate) fn new( queue_style: QueueStyle, max_queue_size_per_key: NonZeroUsize, counters: Option<&'static IntCounterVec>, - ) -> Self - { + ) -> Self { Self { queue_style, max_queue_size: max_queue_size_per_key, diff --git a/core/src/pos/common/channel/src/message_queues_test.rs b/crates/cfxcore/core/src/pos/common/channel/src/message_queues_test.rs similarity index 100% rename from core/src/pos/common/channel/src/message_queues_test.rs rename to crates/cfxcore/core/src/pos/common/channel/src/message_queues_test.rs diff --git a/core/src/pos/common/channel/src/test.rs b/crates/cfxcore/core/src/pos/common/channel/src/test.rs similarity index 100% rename from core/src/pos/common/channel/src/test.rs rename to crates/cfxcore/core/src/pos/common/channel/src/test.rs diff --git a/core/src/pos/common/crash-handler/Cargo.toml b/crates/cfxcore/core/src/pos/common/crash-handler/Cargo.toml similarity index 100% rename from core/src/pos/common/crash-handler/Cargo.toml rename to crates/cfxcore/core/src/pos/common/crash-handler/Cargo.toml diff --git a/core/src/pos/common/crash-handler/src/lib.rs b/crates/cfxcore/core/src/pos/common/crash-handler/src/lib.rs similarity index 100% rename from core/src/pos/common/crash-handler/src/lib.rs rename to crates/cfxcore/core/src/pos/common/crash-handler/src/lib.rs diff --git a/core/src/pos/common/fallible/Cargo.toml b/crates/cfxcore/core/src/pos/common/fallible/Cargo.toml similarity index 100% rename from core/src/pos/common/fallible/Cargo.toml rename to crates/cfxcore/core/src/pos/common/fallible/Cargo.toml diff --git a/core/src/pos/common/fallible/src/copy_from_slice.rs b/crates/cfxcore/core/src/pos/common/fallible/src/copy_from_slice.rs similarity index 100% rename from core/src/pos/common/fallible/src/copy_from_slice.rs rename to crates/cfxcore/core/src/pos/common/fallible/src/copy_from_slice.rs diff --git a/core/src/pos/common/fallible/src/lib.rs b/crates/cfxcore/core/src/pos/common/fallible/src/lib.rs similarity index 100% rename from core/src/pos/common/fallible/src/lib.rs rename to crates/cfxcore/core/src/pos/common/fallible/src/lib.rs diff --git a/core/src/pos/common/infallible/Cargo.toml b/crates/cfxcore/core/src/pos/common/infallible/Cargo.toml similarity index 100% rename from core/src/pos/common/infallible/Cargo.toml rename to crates/cfxcore/core/src/pos/common/infallible/Cargo.toml diff --git a/core/src/pos/common/infallible/src/lib.rs b/crates/cfxcore/core/src/pos/common/infallible/src/lib.rs similarity index 100% rename from core/src/pos/common/infallible/src/lib.rs rename to crates/cfxcore/core/src/pos/common/infallible/src/lib.rs diff --git a/core/src/pos/common/infallible/src/math.rs b/crates/cfxcore/core/src/pos/common/infallible/src/math.rs similarity index 100% rename from core/src/pos/common/infallible/src/math.rs rename to crates/cfxcore/core/src/pos/common/infallible/src/math.rs diff --git a/core/src/pos/common/infallible/src/mutex.rs b/crates/cfxcore/core/src/pos/common/infallible/src/mutex.rs similarity index 100% rename from core/src/pos/common/infallible/src/mutex.rs rename to crates/cfxcore/core/src/pos/common/infallible/src/mutex.rs diff --git a/core/src/pos/common/infallible/src/nonzero.rs b/crates/cfxcore/core/src/pos/common/infallible/src/nonzero.rs similarity index 100% rename from core/src/pos/common/infallible/src/nonzero.rs rename to crates/cfxcore/core/src/pos/common/infallible/src/nonzero.rs diff --git a/core/src/pos/common/infallible/src/rwlock.rs b/crates/cfxcore/core/src/pos/common/infallible/src/rwlock.rs similarity index 100% rename from core/src/pos/common/infallible/src/rwlock.rs rename to crates/cfxcore/core/src/pos/common/infallible/src/rwlock.rs diff --git a/core/src/pos/common/infallible/src/time.rs b/crates/cfxcore/core/src/pos/common/infallible/src/time.rs similarity index 100% rename from core/src/pos/common/infallible/src/time.rs rename to crates/cfxcore/core/src/pos/common/infallible/src/time.rs diff --git a/core/src/pos/common/logger/Cargo.toml b/crates/cfxcore/core/src/pos/common/logger/Cargo.toml similarity index 100% rename from core/src/pos/common/logger/Cargo.toml rename to crates/cfxcore/core/src/pos/common/logger/Cargo.toml diff --git a/core/src/pos/common/logger/derive/Cargo.toml b/crates/cfxcore/core/src/pos/common/logger/derive/Cargo.toml similarity index 100% rename from core/src/pos/common/logger/derive/Cargo.toml rename to crates/cfxcore/core/src/pos/common/logger/derive/Cargo.toml diff --git a/core/src/pos/common/logger/derive/src/lib.rs b/crates/cfxcore/core/src/pos/common/logger/derive/src/lib.rs similarity index 100% rename from core/src/pos/common/logger/derive/src/lib.rs rename to crates/cfxcore/core/src/pos/common/logger/derive/src/lib.rs diff --git a/core/src/pos/common/logger/src/counters.rs b/crates/cfxcore/core/src/pos/common/logger/src/counters.rs similarity index 100% rename from core/src/pos/common/logger/src/counters.rs rename to crates/cfxcore/core/src/pos/common/logger/src/counters.rs diff --git a/core/src/pos/common/logger/src/diem_logger.rs b/crates/cfxcore/core/src/pos/common/logger/src/diem_logger.rs similarity index 99% rename from core/src/pos/common/logger/src/diem_logger.rs rename to crates/cfxcore/core/src/pos/common/logger/src/diem_logger.rs index 8586a7b7bf..5d81394562 100644 --- a/core/src/pos/common/logger/src/diem_logger.rs +++ b/crates/cfxcore/core/src/pos/common/logger/src/diem_logger.rs @@ -112,7 +112,8 @@ impl LogEntry { let mut backtrace = Backtrace::new(); let mut frames = backtrace.frames().to_vec(); if frames.len() > 3 { - frames.drain(0..3); // Remove the first 3 unnecessary frames to simplify + frames.drain(0..3); // Remove the first 3 unnecessary frames + // to simplify // backtrace } backtrace = frames.into(); diff --git a/core/src/pos/common/logger/src/event.rs b/crates/cfxcore/core/src/pos/common/logger/src/event.rs similarity index 98% rename from core/src/pos/common/logger/src/event.rs rename to crates/cfxcore/core/src/pos/common/logger/src/event.rs index 049deee827..7db9344920 100644 --- a/core/src/pos/common/logger/src/event.rs +++ b/crates/cfxcore/core/src/pos/common/logger/src/event.rs @@ -21,8 +21,7 @@ impl<'a> Event<'a> { fn new( metadata: &'a Metadata, message: Option>, keys_and_values: &'a [&'a dyn Schema], - ) -> Self - { + ) -> Self { Self { metadata, message, @@ -33,8 +32,7 @@ impl<'a> Event<'a> { pub fn dispatch( metadata: &'a Metadata, message: Option>, keys_and_values: &'a [&'a dyn Schema], - ) - { + ) { let event = Event::new(metadata, message, keys_and_values); crate::logger::dispatch(&event) } diff --git a/core/src/pos/common/logger/src/filter.rs b/crates/cfxcore/core/src/pos/common/logger/src/filter.rs similarity index 100% rename from core/src/pos/common/logger/src/filter.rs rename to crates/cfxcore/core/src/pos/common/logger/src/filter.rs diff --git a/core/src/pos/common/logger/src/json_log.rs b/crates/cfxcore/core/src/pos/common/logger/src/json_log.rs similarity index 100% rename from core/src/pos/common/logger/src/json_log.rs rename to crates/cfxcore/core/src/pos/common/logger/src/json_log.rs diff --git a/core/src/pos/common/logger/src/kv.rs b/crates/cfxcore/core/src/pos/common/logger/src/kv.rs similarity index 100% rename from core/src/pos/common/logger/src/kv.rs rename to crates/cfxcore/core/src/pos/common/logger/src/kv.rs diff --git a/core/src/pos/common/logger/src/lib.rs b/crates/cfxcore/core/src/pos/common/logger/src/lib.rs similarity index 100% rename from core/src/pos/common/logger/src/lib.rs rename to crates/cfxcore/core/src/pos/common/logger/src/lib.rs diff --git a/core/src/pos/common/logger/src/logger.rs b/crates/cfxcore/core/src/pos/common/logger/src/logger.rs similarity index 100% rename from core/src/pos/common/logger/src/logger.rs rename to crates/cfxcore/core/src/pos/common/logger/src/logger.rs diff --git a/core/src/pos/common/logger/src/macros.rs b/crates/cfxcore/core/src/pos/common/logger/src/macros.rs similarity index 100% rename from core/src/pos/common/logger/src/macros.rs rename to crates/cfxcore/core/src/pos/common/logger/src/macros.rs diff --git a/core/src/pos/common/logger/src/metadata.rs b/crates/cfxcore/core/src/pos/common/logger/src/metadata.rs similarity index 99% rename from core/src/pos/common/logger/src/metadata.rs rename to crates/cfxcore/core/src/pos/common/logger/src/metadata.rs index e95064e064..52a630ce8d 100644 --- a/core/src/pos/common/logger/src/metadata.rs +++ b/crates/cfxcore/core/src/pos/common/logger/src/metadata.rs @@ -35,8 +35,7 @@ impl Metadata { pub const fn new( level: Level, target: &'static str, module_path: &'static str, file: &'static str, line: u32, location: &'static str, - ) -> Self - { + ) -> Self { Self { level, target, diff --git a/core/src/pos/common/logger/src/sample.rs b/crates/cfxcore/core/src/pos/common/logger/src/sample.rs similarity index 100% rename from core/src/pos/common/logger/src/sample.rs rename to crates/cfxcore/core/src/pos/common/logger/src/sample.rs diff --git a/core/src/pos/common/logger/src/security.rs b/crates/cfxcore/core/src/pos/common/logger/src/security.rs similarity index 99% rename from core/src/pos/common/logger/src/security.rs rename to crates/cfxcore/core/src/pos/common/logger/src/security.rs index 4d28327532..2b3215acc8 100644 --- a/core/src/pos/common/logger/src/security.rs +++ b/crates/cfxcore/core/src/pos/common/logger/src/security.rs @@ -19,7 +19,6 @@ //! "some_key" = "some data", //! ); //! ``` -//! use crate::{Key, Schema, Value, Visitor}; use serde::{Deserialize, Serialize}; diff --git a/core/src/pos/common/logger/src/struct_log.rs b/crates/cfxcore/core/src/pos/common/logger/src/struct_log.rs similarity index 100% rename from core/src/pos/common/logger/src/struct_log.rs rename to crates/cfxcore/core/src/pos/common/logger/src/struct_log.rs diff --git a/core/src/pos/common/logger/tests/derive.rs b/crates/cfxcore/core/src/pos/common/logger/tests/derive.rs similarity index 100% rename from core/src/pos/common/logger/tests/derive.rs rename to crates/cfxcore/core/src/pos/common/logger/tests/derive.rs diff --git a/core/src/pos/common/logger/tests/logger.rs b/crates/cfxcore/core/src/pos/common/logger/tests/logger.rs similarity index 100% rename from core/src/pos/common/logger/tests/logger.rs rename to crates/cfxcore/core/src/pos/common/logger/tests/logger.rs diff --git a/core/src/pos/common/logger/tests/logger_custom_format.rs b/crates/cfxcore/core/src/pos/common/logger/tests/logger_custom_format.rs similarity index 100% rename from core/src/pos/common/logger/tests/logger_custom_format.rs rename to crates/cfxcore/core/src/pos/common/logger/tests/logger_custom_format.rs diff --git a/core/src/pos/common/logger/tests/remote.rs b/crates/cfxcore/core/src/pos/common/logger/tests/remote.rs similarity index 100% rename from core/src/pos/common/logger/tests/remote.rs rename to crates/cfxcore/core/src/pos/common/logger/tests/remote.rs diff --git a/core/src/pos/common/metrics-core/Cargo.toml b/crates/cfxcore/core/src/pos/common/metrics-core/Cargo.toml similarity index 100% rename from core/src/pos/common/metrics-core/Cargo.toml rename to crates/cfxcore/core/src/pos/common/metrics-core/Cargo.toml diff --git a/core/src/pos/common/metrics-core/src/lib.rs b/crates/cfxcore/core/src/pos/common/metrics-core/src/lib.rs similarity index 100% rename from core/src/pos/common/metrics-core/src/lib.rs rename to crates/cfxcore/core/src/pos/common/metrics-core/src/lib.rs diff --git a/core/src/pos/common/metrics/Cargo.toml b/crates/cfxcore/core/src/pos/common/metrics/Cargo.toml similarity index 100% rename from core/src/pos/common/metrics/Cargo.toml rename to crates/cfxcore/core/src/pos/common/metrics/Cargo.toml diff --git a/core/src/pos/common/metrics/build.rs b/crates/cfxcore/core/src/pos/common/metrics/build.rs similarity index 100% rename from core/src/pos/common/metrics/build.rs rename to crates/cfxcore/core/src/pos/common/metrics/build.rs diff --git a/core/src/pos/common/metrics/src/json_encoder.rs b/crates/cfxcore/core/src/pos/common/metrics/src/json_encoder.rs similarity index 100% rename from core/src/pos/common/metrics/src/json_encoder.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/json_encoder.rs diff --git a/core/src/pos/common/metrics/src/json_metrics.rs b/crates/cfxcore/core/src/pos/common/metrics/src/json_metrics.rs similarity index 100% rename from core/src/pos/common/metrics/src/json_metrics.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/json_metrics.rs diff --git a/core/src/pos/common/metrics/src/lib.rs b/crates/cfxcore/core/src/pos/common/metrics/src/lib.rs similarity index 100% rename from core/src/pos/common/metrics/src/lib.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/lib.rs diff --git a/core/src/pos/common/metrics/src/metric_server.rs b/crates/cfxcore/core/src/pos/common/metrics/src/metric_server.rs similarity index 100% rename from core/src/pos/common/metrics/src/metric_server.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/metric_server.rs diff --git a/core/src/pos/common/metrics/src/op_counters.rs b/crates/cfxcore/core/src/pos/common/metrics/src/op_counters.rs similarity index 100% rename from core/src/pos/common/metrics/src/op_counters.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/op_counters.rs diff --git a/core/src/pos/common/metrics/src/public_metrics.rs b/crates/cfxcore/core/src/pos/common/metrics/src/public_metrics.rs similarity index 100% rename from core/src/pos/common/metrics/src/public_metrics.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/public_metrics.rs diff --git a/core/src/pos/common/metrics/src/unit_tests/lib_test.rs b/crates/cfxcore/core/src/pos/common/metrics/src/unit_tests/lib_test.rs similarity index 100% rename from core/src/pos/common/metrics/src/unit_tests/lib_test.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/unit_tests/lib_test.rs diff --git a/core/src/pos/common/metrics/src/unit_tests/mod.rs b/crates/cfxcore/core/src/pos/common/metrics/src/unit_tests/mod.rs similarity index 100% rename from core/src/pos/common/metrics/src/unit_tests/mod.rs rename to crates/cfxcore/core/src/pos/common/metrics/src/unit_tests/mod.rs diff --git a/core/src/pos/common/nibble/Cargo.toml b/crates/cfxcore/core/src/pos/common/nibble/Cargo.toml similarity index 100% rename from core/src/pos/common/nibble/Cargo.toml rename to crates/cfxcore/core/src/pos/common/nibble/Cargo.toml diff --git a/core/src/pos/common/nibble/src/lib.rs b/crates/cfxcore/core/src/pos/common/nibble/src/lib.rs similarity index 100% rename from core/src/pos/common/nibble/src/lib.rs rename to crates/cfxcore/core/src/pos/common/nibble/src/lib.rs diff --git a/core/src/pos/common/num-variants/Cargo.toml b/crates/cfxcore/core/src/pos/common/num-variants/Cargo.toml similarity index 100% rename from core/src/pos/common/num-variants/Cargo.toml rename to crates/cfxcore/core/src/pos/common/num-variants/Cargo.toml diff --git a/core/src/pos/common/num-variants/src/lib.rs b/crates/cfxcore/core/src/pos/common/num-variants/src/lib.rs similarity index 100% rename from core/src/pos/common/num-variants/src/lib.rs rename to crates/cfxcore/core/src/pos/common/num-variants/src/lib.rs diff --git a/core/src/pos/common/num-variants/tests/basic.rs b/crates/cfxcore/core/src/pos/common/num-variants/tests/basic.rs similarity index 100% rename from core/src/pos/common/num-variants/tests/basic.rs rename to crates/cfxcore/core/src/pos/common/num-variants/tests/basic.rs diff --git a/core/src/pos/common/proptest-helpers/Cargo.toml b/crates/cfxcore/core/src/pos/common/proptest-helpers/Cargo.toml similarity index 100% rename from core/src/pos/common/proptest-helpers/Cargo.toml rename to crates/cfxcore/core/src/pos/common/proptest-helpers/Cargo.toml diff --git a/core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/growing_subset_tests.txt b/crates/cfxcore/core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/growing_subset_tests.txt similarity index 100% rename from core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/growing_subset_tests.txt rename to crates/cfxcore/core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/growing_subset_tests.txt diff --git a/core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/repeat_vec_tests.txt b/crates/cfxcore/core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/repeat_vec_tests.txt similarity index 100% rename from core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/repeat_vec_tests.txt rename to crates/cfxcore/core/src/pos/common/proptest-helpers/proptest-regressions/unit_tests/repeat_vec_tests.txt diff --git a/core/src/pos/common/proptest-helpers/src/growing_subset.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/growing_subset.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/growing_subset.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/growing_subset.rs diff --git a/core/src/pos/common/proptest-helpers/src/lib.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/lib.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/lib.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/lib.rs diff --git a/core/src/pos/common/proptest-helpers/src/repeat_vec.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/repeat_vec.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/repeat_vec.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/repeat_vec.rs diff --git a/core/src/pos/common/proptest-helpers/src/unit_tests.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/unit_tests.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests.rs diff --git a/core/src/pos/common/proptest-helpers/src/unit_tests/growing_subset_tests.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests/growing_subset_tests.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/unit_tests/growing_subset_tests.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests/growing_subset_tests.rs diff --git a/core/src/pos/common/proptest-helpers/src/unit_tests/pick_idx_tests.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests/pick_idx_tests.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/unit_tests/pick_idx_tests.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests/pick_idx_tests.rs diff --git a/core/src/pos/common/proptest-helpers/src/unit_tests/repeat_vec_tests.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests/repeat_vec_tests.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/unit_tests/repeat_vec_tests.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/unit_tests/repeat_vec_tests.rs diff --git a/core/src/pos/common/proptest-helpers/src/value_generator.rs b/crates/cfxcore/core/src/pos/common/proptest-helpers/src/value_generator.rs similarity index 100% rename from core/src/pos/common/proptest-helpers/src/value_generator.rs rename to crates/cfxcore/core/src/pos/common/proptest-helpers/src/value_generator.rs diff --git a/core/src/pos/common/proxy/Cargo.toml b/crates/cfxcore/core/src/pos/common/proxy/Cargo.toml similarity index 100% rename from core/src/pos/common/proxy/Cargo.toml rename to crates/cfxcore/core/src/pos/common/proxy/Cargo.toml diff --git a/core/src/pos/common/proxy/src/lib.rs b/crates/cfxcore/core/src/pos/common/proxy/src/lib.rs similarity index 100% rename from core/src/pos/common/proxy/src/lib.rs rename to crates/cfxcore/core/src/pos/common/proxy/src/lib.rs diff --git a/core/src/pos/common/short-hex-str/Cargo.toml b/crates/cfxcore/core/src/pos/common/short-hex-str/Cargo.toml similarity index 100% rename from core/src/pos/common/short-hex-str/Cargo.toml rename to crates/cfxcore/core/src/pos/common/short-hex-str/Cargo.toml diff --git a/core/src/pos/common/short-hex-str/src/lib.rs b/crates/cfxcore/core/src/pos/common/short-hex-str/src/lib.rs similarity index 100% rename from core/src/pos/common/short-hex-str/src/lib.rs rename to crates/cfxcore/core/src/pos/common/short-hex-str/src/lib.rs diff --git a/core/src/pos/common/subscription-service/Cargo.toml b/crates/cfxcore/core/src/pos/common/subscription-service/Cargo.toml similarity index 100% rename from core/src/pos/common/subscription-service/Cargo.toml rename to crates/cfxcore/core/src/pos/common/subscription-service/Cargo.toml diff --git a/core/src/pos/common/subscription-service/src/lib.rs b/crates/cfxcore/core/src/pos/common/subscription-service/src/lib.rs similarity index 100% rename from core/src/pos/common/subscription-service/src/lib.rs rename to crates/cfxcore/core/src/pos/common/subscription-service/src/lib.rs diff --git a/core/src/pos/common/temppath/Cargo.toml b/crates/cfxcore/core/src/pos/common/temppath/Cargo.toml similarity index 100% rename from core/src/pos/common/temppath/Cargo.toml rename to crates/cfxcore/core/src/pos/common/temppath/Cargo.toml diff --git a/core/src/pos/common/temppath/src/lib.rs b/crates/cfxcore/core/src/pos/common/temppath/src/lib.rs similarity index 100% rename from core/src/pos/common/temppath/src/lib.rs rename to crates/cfxcore/core/src/pos/common/temppath/src/lib.rs diff --git a/core/src/pos/common/time-service/Cargo.toml b/crates/cfxcore/core/src/pos/common/time-service/Cargo.toml similarity index 100% rename from core/src/pos/common/time-service/Cargo.toml rename to crates/cfxcore/core/src/pos/common/time-service/Cargo.toml diff --git a/core/src/pos/common/time-service/src/interval.rs b/crates/cfxcore/core/src/pos/common/time-service/src/interval.rs similarity index 100% rename from core/src/pos/common/time-service/src/interval.rs rename to crates/cfxcore/core/src/pos/common/time-service/src/interval.rs diff --git a/core/src/pos/common/time-service/src/lib.rs b/crates/cfxcore/core/src/pos/common/time-service/src/lib.rs similarity index 100% rename from core/src/pos/common/time-service/src/lib.rs rename to crates/cfxcore/core/src/pos/common/time-service/src/lib.rs diff --git a/core/src/pos/common/time-service/src/mock.rs b/crates/cfxcore/core/src/pos/common/time-service/src/mock.rs similarity index 100% rename from core/src/pos/common/time-service/src/mock.rs rename to crates/cfxcore/core/src/pos/common/time-service/src/mock.rs diff --git a/core/src/pos/common/time-service/src/real.rs b/crates/cfxcore/core/src/pos/common/time-service/src/real.rs similarity index 100% rename from core/src/pos/common/time-service/src/real.rs rename to crates/cfxcore/core/src/pos/common/time-service/src/real.rs diff --git a/core/src/pos/common/time-service/src/timeout.rs b/crates/cfxcore/core/src/pos/common/time-service/src/timeout.rs similarity index 100% rename from core/src/pos/common/time-service/src/timeout.rs rename to crates/cfxcore/core/src/pos/common/time-service/src/timeout.rs diff --git a/core/src/pos/config/Cargo.toml b/crates/cfxcore/core/src/pos/config/Cargo.toml similarity index 91% rename from core/src/pos/config/Cargo.toml rename to crates/cfxcore/core/src/pos/config/Cargo.toml index d82db8ffe9..6f6c70a39e 100644 --- a/core/src/pos/config/Cargo.toml +++ b/crates/cfxcore/core/src/pos/config/Cargo.toml @@ -21,14 +21,14 @@ thiserror = "1.0.24" bcs = "0.1.2" diem-crypto = { path = "../crypto/crypto" } diem-crypto-derive = { path = "../crypto/crypto-derive" } -diem-global-constants = { path = "./global-constants"} +diem-global-constants = { path = "global-constants" } diem-logger = { path = "../common/logger" } diem-network-address-encryption = { path = "management/network-address-encryption" } diem-secure-storage = { path = "../secure/storage" } diem-temppath = { path = "../common/temppath" } diem-types = { path = "../types" } short-hex-str = { path = "../common/short-hex-str" } -cfx-types = {path = "../../../../cfx_types"} +cfx-types = {path = "../../../../../cfx_types" } [dev-dependencies] diem-crypto = { path = "../crypto/crypto", features = ["fuzzing"] } diff --git a/core/src/pos/config/README.md b/crates/cfxcore/core/src/pos/config/README.md similarity index 100% rename from core/src/pos/config/README.md rename to crates/cfxcore/core/src/pos/config/README.md diff --git a/core/src/pos/config/data/metrics/prometheus.yml b/crates/cfxcore/core/src/pos/config/data/metrics/prometheus.yml similarity index 100% rename from core/src/pos/config/data/metrics/prometheus.yml rename to crates/cfxcore/core/src/pos/config/data/metrics/prometheus.yml diff --git a/core/src/pos/config/generate-key/Cargo.toml b/crates/cfxcore/core/src/pos/config/generate-key/Cargo.toml similarity index 100% rename from core/src/pos/config/generate-key/Cargo.toml rename to crates/cfxcore/core/src/pos/config/generate-key/Cargo.toml diff --git a/core/src/pos/config/generate-key/src/lib.rs b/crates/cfxcore/core/src/pos/config/generate-key/src/lib.rs similarity index 100% rename from core/src/pos/config/generate-key/src/lib.rs rename to crates/cfxcore/core/src/pos/config/generate-key/src/lib.rs diff --git a/core/src/pos/config/generate-key/src/main.rs b/crates/cfxcore/core/src/pos/config/generate-key/src/main.rs similarity index 100% rename from core/src/pos/config/generate-key/src/main.rs rename to crates/cfxcore/core/src/pos/config/generate-key/src/main.rs diff --git a/core/src/pos/config/global-constants/Cargo.toml b/crates/cfxcore/core/src/pos/config/global-constants/Cargo.toml similarity index 100% rename from core/src/pos/config/global-constants/Cargo.toml rename to crates/cfxcore/core/src/pos/config/global-constants/Cargo.toml diff --git a/core/src/pos/config/global-constants/src/lib.rs b/crates/cfxcore/core/src/pos/config/global-constants/src/lib.rs similarity index 100% rename from core/src/pos/config/global-constants/src/lib.rs rename to crates/cfxcore/core/src/pos/config/global-constants/src/lib.rs diff --git a/core/src/pos/config/management/Cargo.toml b/crates/cfxcore/core/src/pos/config/management/Cargo.toml similarity index 91% rename from core/src/pos/config/management/Cargo.toml rename to crates/cfxcore/core/src/pos/config/management/Cargo.toml index f41600b642..7051e39a2e 100644 --- a/core/src/pos/config/management/Cargo.toml +++ b/crates/cfxcore/core/src/pos/config/management/Cargo.toml @@ -19,10 +19,10 @@ thiserror = "1.0.24" toml = { version = "0.5.8", default-features = false } bcs = "0.1.2" -diem-config = { path = ".."} +diem-config = { path = ".." } diem-crypto = { path = "../../crypto/crypto" } -diem-global-constants = { path = "../global-constants"} -diem-network-address-encryption = {path = "network-address-encryption"} +diem-global-constants = { path = "../global-constants" } +diem-network-address-encryption = {path = "network-address-encryption" } diem-secure-storage = { path = "../../secure/storage" } diem-time-service = { path = "../../common/time-service" } diem-types = { path = "../../types" } diff --git a/core/src/pos/config/management/README.md b/crates/cfxcore/core/src/pos/config/management/README.md similarity index 100% rename from core/src/pos/config/management/README.md rename to crates/cfxcore/core/src/pos/config/management/README.md diff --git a/core/src/pos/config/management/genesis/Cargo.toml b/crates/cfxcore/core/src/pos/config/management/genesis/Cargo.toml similarity index 97% rename from core/src/pos/config/management/genesis/Cargo.toml rename to crates/cfxcore/core/src/pos/config/management/genesis/Cargo.toml index 2f5a5a5d53..8fbfbc78f2 100644 --- a/core/src/pos/config/management/genesis/Cargo.toml +++ b/crates/cfxcore/core/src/pos/config/management/genesis/Cargo.toml @@ -21,11 +21,11 @@ consensus-types = { path = "../../../consensus/consensus-types" } executor = { path = "../../../execution/executor" } generate-key = { path = "../../generate-key" } bcs = "0.1.2" -diem-config = { path = "../.."} +diem-config = { path = "../.." } diem-crypto = { path = "../../../crypto/crypto" } diem-global-constants = { path = "../../global-constants" } diem-management = { path = ".." } -diem-network-address-encryption = {path = "../network-address-encryption"} +diem-network-address-encryption = {path = "../network-address-encryption" } diem-secure-storage = { path = "../../../secure/storage" } diem-types = { path = "../../../types" } diem-temppath = { path = "../../../common/temppath" } diff --git a/core/src/pos/config/management/genesis/README.md b/crates/cfxcore/core/src/pos/config/management/genesis/README.md similarity index 100% rename from core/src/pos/config/management/genesis/README.md rename to crates/cfxcore/core/src/pos/config/management/genesis/README.md diff --git a/core/src/pos/config/management/genesis/src/command.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/command.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/command.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/command.rs diff --git a/core/src/pos/config/management/genesis/src/config_builder.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/config_builder.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/config_builder.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/config_builder.rs diff --git a/core/src/pos/config/management/genesis/src/genesis.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/genesis.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/genesis.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/genesis.rs diff --git a/core/src/pos/config/management/genesis/src/key.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/key.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/key.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/key.rs diff --git a/core/src/pos/config/management/genesis/src/layout.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/layout.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/layout.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/layout.rs diff --git a/core/src/pos/config/management/genesis/src/lib.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/lib.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/lib.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/lib.rs diff --git a/core/src/pos/config/management/genesis/src/main.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/main.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/main.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/main.rs diff --git a/core/src/pos/config/management/genesis/src/storage_helper.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/storage_helper.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/storage_helper.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/storage_helper.rs diff --git a/core/src/pos/config/management/genesis/src/swarm_config.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/swarm_config.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/swarm_config.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/swarm_config.rs diff --git a/core/src/pos/config/management/genesis/src/validator_config.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/validator_config.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/validator_config.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/validator_config.rs diff --git a/core/src/pos/config/management/genesis/src/validator_operator.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/validator_operator.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/validator_operator.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/validator_operator.rs diff --git a/core/src/pos/config/management/genesis/src/verify.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/verify.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/verify.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/verify.rs diff --git a/core/src/pos/config/management/genesis/src/waypoint.rs b/crates/cfxcore/core/src/pos/config/management/genesis/src/waypoint.rs similarity index 100% rename from core/src/pos/config/management/genesis/src/waypoint.rs rename to crates/cfxcore/core/src/pos/config/management/genesis/src/waypoint.rs diff --git a/core/src/pos/config/management/network-address-encryption/Cargo.toml b/crates/cfxcore/core/src/pos/config/management/network-address-encryption/Cargo.toml similarity index 92% rename from core/src/pos/config/management/network-address-encryption/Cargo.toml rename to crates/cfxcore/core/src/pos/config/management/network-address-encryption/Cargo.toml index 761bbcdc37..e857fde12e 100644 --- a/core/src/pos/config/management/network-address-encryption/Cargo.toml +++ b/crates/cfxcore/core/src/pos/config/management/network-address-encryption/Cargo.toml @@ -15,7 +15,7 @@ serde = { version = "1.0.124", features = ["rc"], default-features = false } thiserror = "1.0.24" bcs = "0.1.2" -diem-global-constants = { path = "../../global-constants"} +diem-global-constants = { path = "../../global-constants" } diem-infallible = { path = "../../../common/infallible" } diem-logger = { path = "../../../common/logger" } diem-secure-storage = { path = "../../../secure/storage" } diff --git a/core/src/pos/config/management/network-address-encryption/src/lib.rs b/crates/cfxcore/core/src/pos/config/management/network-address-encryption/src/lib.rs similarity index 99% rename from core/src/pos/config/management/network-address-encryption/src/lib.rs rename to crates/cfxcore/core/src/pos/config/management/network-address-encryption/src/lib.rs index 177377e503..af98f1d994 100644 --- a/core/src/pos/config/management/network-address-encryption/src/lib.rs +++ b/crates/cfxcore/core/src/pos/config/management/network-address-encryption/src/lib.rs @@ -92,8 +92,7 @@ impl Encryptor { pub fn encrypt( &self, network_addresses: &[NetworkAddress], account: AccountAddress, seq_num: u64, - ) -> Result, Error> - { + ) -> Result, Error> { let keys = self.read()?; let key = keys .keys diff --git a/core/src/pos/config/management/operational/Cargo.toml b/crates/cfxcore/core/src/pos/config/management/operational/Cargo.toml similarity index 96% rename from core/src/pos/config/management/operational/Cargo.toml rename to crates/cfxcore/core/src/pos/config/management/operational/Cargo.toml index a7deedb0c1..c0a187cb2d 100644 --- a/core/src/pos/config/management/operational/Cargo.toml +++ b/crates/cfxcore/core/src/pos/config/management/operational/Cargo.toml @@ -20,11 +20,11 @@ toml = { version = "0.5.8", default-features = false } bcs = "0.1.2" diem-client = { path = "../../../sdk/client", features = ["blocking"], default-features = false } -diem-config = { path = "../.."} +diem-config = { path = "../.." } diem-crypto = { path = "../../../crypto/crypto" } diem-global-constants = { path = "../../global-constants" } diem-management = { path = ".." } -diem-network-address-encryption = {path = "../network-address-encryption"} +diem-network-address-encryption = {path = "../network-address-encryption" } diem-secure-storage = { path = "../../../secure/storage" } diem-types = { path = "../../../types" } diem-temppath = { path = "../../../common/temppath" } diff --git a/core/src/pos/config/management/operational/README.md b/crates/cfxcore/core/src/pos/config/management/operational/README.md similarity index 100% rename from core/src/pos/config/management/operational/README.md rename to crates/cfxcore/core/src/pos/config/management/operational/README.md diff --git a/core/src/pos/config/management/operational/src/account_resource.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/account_resource.rs similarity index 100% rename from core/src/pos/config/management/operational/src/account_resource.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/account_resource.rs diff --git a/core/src/pos/config/management/operational/src/auto_validate.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/auto_validate.rs similarity index 100% rename from core/src/pos/config/management/operational/src/auto_validate.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/auto_validate.rs diff --git a/core/src/pos/config/management/operational/src/command.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/command.rs similarity index 100% rename from core/src/pos/config/management/operational/src/command.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/command.rs diff --git a/core/src/pos/config/management/operational/src/governance.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/governance.rs similarity index 100% rename from core/src/pos/config/management/operational/src/governance.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/governance.rs diff --git a/core/src/pos/config/management/operational/src/json_rpc.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/json_rpc.rs similarity index 100% rename from core/src/pos/config/management/operational/src/json_rpc.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/json_rpc.rs diff --git a/core/src/pos/config/management/operational/src/keys.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/keys.rs similarity index 100% rename from core/src/pos/config/management/operational/src/keys.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/keys.rs diff --git a/core/src/pos/config/management/operational/src/lib.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/lib.rs similarity index 100% rename from core/src/pos/config/management/operational/src/lib.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/lib.rs diff --git a/core/src/pos/config/management/operational/src/main.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/main.rs similarity index 100% rename from core/src/pos/config/management/operational/src/main.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/main.rs diff --git a/core/src/pos/config/management/operational/src/network_checker.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/network_checker.rs similarity index 100% rename from core/src/pos/config/management/operational/src/network_checker.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/network_checker.rs diff --git a/core/src/pos/config/management/operational/src/owner.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/owner.rs similarity index 100% rename from core/src/pos/config/management/operational/src/owner.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/owner.rs diff --git a/core/src/pos/config/management/operational/src/print.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/print.rs similarity index 100% rename from core/src/pos/config/management/operational/src/print.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/print.rs diff --git a/core/src/pos/config/management/operational/src/test_helper.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/test_helper.rs similarity index 100% rename from core/src/pos/config/management/operational/src/test_helper.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/test_helper.rs diff --git a/core/src/pos/config/management/operational/src/validate_transaction.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/validate_transaction.rs similarity index 100% rename from core/src/pos/config/management/operational/src/validate_transaction.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/validate_transaction.rs diff --git a/core/src/pos/config/management/operational/src/validator_config.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/validator_config.rs similarity index 100% rename from core/src/pos/config/management/operational/src/validator_config.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/validator_config.rs diff --git a/core/src/pos/config/management/operational/src/validator_set.rs b/crates/cfxcore/core/src/pos/config/management/operational/src/validator_set.rs similarity index 100% rename from core/src/pos/config/management/operational/src/validator_set.rs rename to crates/cfxcore/core/src/pos/config/management/operational/src/validator_set.rs diff --git a/core/src/pos/config/management/src/config.rs b/crates/cfxcore/core/src/pos/config/management/src/config.rs similarity index 100% rename from core/src/pos/config/management/src/config.rs rename to crates/cfxcore/core/src/pos/config/management/src/config.rs diff --git a/core/src/pos/config/management/src/error.rs b/crates/cfxcore/core/src/pos/config/management/src/error.rs similarity index 100% rename from core/src/pos/config/management/src/error.rs rename to crates/cfxcore/core/src/pos/config/management/src/error.rs diff --git a/core/src/pos/config/management/src/lib.rs b/crates/cfxcore/core/src/pos/config/management/src/lib.rs similarity index 100% rename from core/src/pos/config/management/src/lib.rs rename to crates/cfxcore/core/src/pos/config/management/src/lib.rs diff --git a/core/src/pos/config/management/src/secure_backend.rs b/crates/cfxcore/core/src/pos/config/management/src/secure_backend.rs similarity index 100% rename from core/src/pos/config/management/src/secure_backend.rs rename to crates/cfxcore/core/src/pos/config/management/src/secure_backend.rs diff --git a/core/src/pos/config/management/src/storage.rs b/crates/cfxcore/core/src/pos/config/management/src/storage.rs similarity index 100% rename from core/src/pos/config/management/src/storage.rs rename to crates/cfxcore/core/src/pos/config/management/src/storage.rs diff --git a/core/src/pos/config/management/src/transaction.rs b/crates/cfxcore/core/src/pos/config/management/src/transaction.rs similarity index 100% rename from core/src/pos/config/management/src/transaction.rs rename to crates/cfxcore/core/src/pos/config/management/src/transaction.rs diff --git a/core/src/pos/config/management/src/validator_config.rs b/crates/cfxcore/core/src/pos/config/management/src/validator_config.rs similarity index 100% rename from core/src/pos/config/management/src/validator_config.rs rename to crates/cfxcore/core/src/pos/config/management/src/validator_config.rs diff --git a/core/src/pos/config/management/src/waypoint.rs b/crates/cfxcore/core/src/pos/config/management/src/waypoint.rs similarity index 100% rename from core/src/pos/config/management/src/waypoint.rs rename to crates/cfxcore/core/src/pos/config/management/src/waypoint.rs diff --git a/core/src/pos/config/seed-peer-generator/Cargo.toml b/crates/cfxcore/core/src/pos/config/seed-peer-generator/Cargo.toml similarity index 100% rename from core/src/pos/config/seed-peer-generator/Cargo.toml rename to crates/cfxcore/core/src/pos/config/seed-peer-generator/Cargo.toml diff --git a/core/src/pos/config/seed-peer-generator/src/lib.rs b/crates/cfxcore/core/src/pos/config/seed-peer-generator/src/lib.rs similarity index 100% rename from core/src/pos/config/seed-peer-generator/src/lib.rs rename to crates/cfxcore/core/src/pos/config/seed-peer-generator/src/lib.rs diff --git a/core/src/pos/config/seed-peer-generator/src/main.rs b/crates/cfxcore/core/src/pos/config/seed-peer-generator/src/main.rs similarity index 100% rename from core/src/pos/config/seed-peer-generator/src/main.rs rename to crates/cfxcore/core/src/pos/config/seed-peer-generator/src/main.rs diff --git a/core/src/pos/config/seed-peer-generator/src/utils.rs b/crates/cfxcore/core/src/pos/config/seed-peer-generator/src/utils.rs similarity index 100% rename from core/src/pos/config/seed-peer-generator/src/utils.rs rename to crates/cfxcore/core/src/pos/config/seed-peer-generator/src/utils.rs diff --git a/core/src/pos/config/src/config/consensus_config.rs b/crates/cfxcore/core/src/pos/config/src/config/consensus_config.rs similarity index 100% rename from core/src/pos/config/src/config/consensus_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/consensus_config.rs diff --git a/core/src/pos/config/src/config/debug_interface_config.rs b/crates/cfxcore/core/src/pos/config/src/config/debug_interface_config.rs similarity index 100% rename from core/src/pos/config/src/config/debug_interface_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/debug_interface_config.rs diff --git a/core/src/pos/config/src/config/error.rs b/crates/cfxcore/core/src/pos/config/src/config/error.rs similarity index 100% rename from core/src/pos/config/src/config/error.rs rename to crates/cfxcore/core/src/pos/config/src/config/error.rs diff --git a/core/src/pos/config/src/config/execution_config.rs b/crates/cfxcore/core/src/pos/config/src/config/execution_config.rs similarity index 100% rename from core/src/pos/config/src/config/execution_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/execution_config.rs diff --git a/core/src/pos/config/src/config/json_rpc_config.rs b/crates/cfxcore/core/src/pos/config/src/config/json_rpc_config.rs similarity index 100% rename from core/src/pos/config/src/config/json_rpc_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/json_rpc_config.rs diff --git a/core/src/pos/config/src/config/key_manager_config.rs b/crates/cfxcore/core/src/pos/config/src/config/key_manager_config.rs similarity index 100% rename from core/src/pos/config/src/config/key_manager_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/key_manager_config.rs diff --git a/core/src/pos/config/src/config/logger_config.rs b/crates/cfxcore/core/src/pos/config/src/config/logger_config.rs similarity index 100% rename from core/src/pos/config/src/config/logger_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/logger_config.rs diff --git a/core/src/pos/config/src/config/mempool_config.rs b/crates/cfxcore/core/src/pos/config/src/config/mempool_config.rs similarity index 100% rename from core/src/pos/config/src/config/mempool_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/mempool_config.rs diff --git a/core/src/pos/config/src/config/metrics_config.rs b/crates/cfxcore/core/src/pos/config/src/config/metrics_config.rs similarity index 100% rename from core/src/pos/config/src/config/metrics_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/metrics_config.rs diff --git a/core/src/pos/config/src/config/mod.rs b/crates/cfxcore/core/src/pos/config/src/config/mod.rs similarity index 100% rename from core/src/pos/config/src/config/mod.rs rename to crates/cfxcore/core/src/pos/config/src/config/mod.rs diff --git a/core/src/pos/config/src/config/network_config.rs b/crates/cfxcore/core/src/pos/config/src/config/network_config.rs similarity index 99% rename from core/src/pos/config/src/config/network_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/network_config.rs index f142096d77..8a33414e7d 100644 --- a/core/src/pos/config/src/config/network_config.rs +++ b/crates/cfxcore/core/src/pos/config/src/config/network_config.rs @@ -436,8 +436,7 @@ impl Peer { pub fn new( addresses: Vec, mut keys: HashSet, role: PeerRole, - ) -> Peer - { + ) -> Peer { let addr_keys = addresses .iter() .filter_map(NetworkAddress::find_noise_proto); diff --git a/core/src/pos/config/src/config/safety_rules_config.rs b/crates/cfxcore/core/src/pos/config/src/config/safety_rules_config.rs similarity index 100% rename from core/src/pos/config/src/config/safety_rules_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/safety_rules_config.rs diff --git a/core/src/pos/config/src/config/secure_backend_config.rs b/crates/cfxcore/core/src/pos/config/src/config/secure_backend_config.rs similarity index 100% rename from core/src/pos/config/src/config/secure_backend_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/secure_backend_config.rs diff --git a/core/src/pos/config/src/config/state_sync_config.rs b/crates/cfxcore/core/src/pos/config/src/config/state_sync_config.rs similarity index 100% rename from core/src/pos/config/src/config/state_sync_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/state_sync_config.rs diff --git a/core/src/pos/config/src/config/storage_config.rs b/crates/cfxcore/core/src/pos/config/src/config/storage_config.rs similarity index 100% rename from core/src/pos/config/src/config/storage_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/storage_config.rs diff --git a/core/src/pos/config/src/config/test_config.rs b/crates/cfxcore/core/src/pos/config/src/config/test_config.rs similarity index 100% rename from core/src/pos/config/src/config/test_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/test_config.rs diff --git a/core/src/pos/config/src/config/test_data/public_full_node.yaml b/crates/cfxcore/core/src/pos/config/src/config/test_data/public_full_node.yaml similarity index 100% rename from core/src/pos/config/src/config/test_data/public_full_node.yaml rename to crates/cfxcore/core/src/pos/config/src/config/test_data/public_full_node.yaml diff --git a/core/src/pos/config/src/config/test_data/safety_rules.yaml b/crates/cfxcore/core/src/pos/config/src/config/test_data/safety_rules.yaml similarity index 100% rename from core/src/pos/config/src/config/test_data/safety_rules.yaml rename to crates/cfxcore/core/src/pos/config/src/config/test_data/safety_rules.yaml diff --git a/core/src/pos/config/src/config/test_data/validator.yaml b/crates/cfxcore/core/src/pos/config/src/config/test_data/validator.yaml similarity index 100% rename from core/src/pos/config/src/config/test_data/validator.yaml rename to crates/cfxcore/core/src/pos/config/src/config/test_data/validator.yaml diff --git a/core/src/pos/config/src/config/test_data/validator_full_node.yaml b/crates/cfxcore/core/src/pos/config/src/config/test_data/validator_full_node.yaml similarity index 100% rename from core/src/pos/config/src/config/test_data/validator_full_node.yaml rename to crates/cfxcore/core/src/pos/config/src/config/test_data/validator_full_node.yaml diff --git a/core/src/pos/config/src/config/upstream_config.rs b/crates/cfxcore/core/src/pos/config/src/config/upstream_config.rs similarity index 100% rename from core/src/pos/config/src/config/upstream_config.rs rename to crates/cfxcore/core/src/pos/config/src/config/upstream_config.rs diff --git a/core/src/pos/config/src/generator.rs b/crates/cfxcore/core/src/pos/config/src/generator.rs similarity index 100% rename from core/src/pos/config/src/generator.rs rename to crates/cfxcore/core/src/pos/config/src/generator.rs diff --git a/core/src/pos/config/src/keys.rs b/crates/cfxcore/core/src/pos/config/src/keys.rs similarity index 99% rename from core/src/pos/config/src/keys.rs rename to crates/cfxcore/core/src/pos/config/src/keys.rs index 7ce989da7d..693a2a1699 100644 --- a/core/src/pos/config/src/keys.rs +++ b/crates/cfxcore/core/src/pos/config/src/keys.rs @@ -14,7 +14,6 @@ //! //! The public key part is dynamically derived during deserialization, //! while ignored during serialization. -//! use diem_crypto::PrivateKey; use serde::{de::DeserializeOwned, Deserialize, Serialize}; diff --git a/core/src/pos/config/src/lib.rs b/crates/cfxcore/core/src/pos/config/src/lib.rs similarity index 100% rename from core/src/pos/config/src/lib.rs rename to crates/cfxcore/core/src/pos/config/src/lib.rs diff --git a/core/src/pos/config/src/network_id.rs b/crates/cfxcore/core/src/pos/config/src/network_id.rs similarity index 100% rename from core/src/pos/config/src/network_id.rs rename to crates/cfxcore/core/src/pos/config/src/network_id.rs diff --git a/core/src/pos/config/src/utils.rs b/crates/cfxcore/core/src/pos/config/src/utils.rs similarity index 100% rename from core/src/pos/config/src/utils.rs rename to crates/cfxcore/core/src/pos/config/src/utils.rs diff --git a/core/src/pos/consensus/block_storage/block_store.rs b/crates/cfxcore/core/src/pos/consensus/block_storage/block_store.rs similarity index 99% rename from core/src/pos/consensus/block_storage/block_store.rs rename to crates/cfxcore/core/src/pos/consensus/block_storage/block_store.rs index 27546e77f3..b779b30695 100644 --- a/core/src/pos/consensus/block_storage/block_store.rs +++ b/crates/cfxcore/core/src/pos/consensus/block_storage/block_store.rs @@ -115,8 +115,7 @@ impl BlockStore { initial_data: RecoveryData, state_computer: Arc, max_pruned_blocks_in_mem: usize, time_service: Arc, pow_handler: Arc, - ) -> Self - { + ) -> Self { let highest_tc = initial_data.highest_timeout_certificate(); let (root, root_metadata, blocks, quorum_certs) = initial_data.take(); Self::build( @@ -141,8 +140,7 @@ impl BlockStore { storage: Arc, max_pruned_blocks_in_mem: usize, time_service: Arc, pow_handler: Arc, - ) -> Self - { + ) -> Self { let RootInfo(root_block, root_qc, root_li) = root; //verify root is correct assert_eq!( diff --git a/core/src/pos/consensus/block_storage/block_store_and_lec_recovery_test.rs b/crates/cfxcore/core/src/pos/consensus/block_storage/block_store_and_lec_recovery_test.rs similarity index 100% rename from core/src/pos/consensus/block_storage/block_store_and_lec_recovery_test.rs rename to crates/cfxcore/core/src/pos/consensus/block_storage/block_store_and_lec_recovery_test.rs diff --git a/core/src/pos/consensus/block_storage/block_store_test.rs b/crates/cfxcore/core/src/pos/consensus/block_storage/block_store_test.rs similarity index 100% rename from core/src/pos/consensus/block_storage/block_store_test.rs rename to crates/cfxcore/core/src/pos/consensus/block_storage/block_store_test.rs diff --git a/core/src/pos/consensus/block_storage/block_tree.rs b/crates/cfxcore/core/src/pos/consensus/block_storage/block_tree.rs similarity index 99% rename from core/src/pos/consensus/block_storage/block_tree.rs rename to crates/cfxcore/core/src/pos/consensus/block_storage/block_tree.rs index df71eac9c9..9c3672c5a3 100644 --- a/core/src/pos/consensus/block_storage/block_tree.rs +++ b/crates/cfxcore/core/src/pos/consensus/block_storage/block_tree.rs @@ -88,8 +88,7 @@ impl BlockTree { root: ExecutedBlock, root_quorum_cert: QuorumCert, root_ledger_info: QuorumCert, max_pruned_blocks_in_mem: usize, highest_timeout_cert: Option>, - ) -> Self - { + ) -> Self { assert_eq!( root.id(), root_ledger_info.commit_info().id(), @@ -320,8 +319,7 @@ impl BlockTree { pub(super) fn process_pruned_blocks( &mut self, root_id: HashValue, mut newly_pruned_blocks: VecDeque, - ) - { + ) { assert!(self.block_exists(&root_id)); // Update the next root self.root_id = root_id; diff --git a/core/src/pos/consensus/block_storage/mod.rs b/crates/cfxcore/core/src/pos/consensus/block_storage/mod.rs similarity index 100% rename from core/src/pos/consensus/block_storage/mod.rs rename to crates/cfxcore/core/src/pos/consensus/block_storage/mod.rs diff --git a/core/src/pos/consensus/block_storage/sync_manager.rs b/crates/cfxcore/core/src/pos/consensus/block_storage/sync_manager.rs similarity index 99% rename from core/src/pos/consensus/block_storage/sync_manager.rs rename to crates/cfxcore/core/src/pos/consensus/block_storage/sync_manager.rs index c9a8159bbe..2076b4c8af 100644 --- a/core/src/pos/consensus/block_storage/sync_manager.rs +++ b/crates/cfxcore/core/src/pos/consensus/block_storage/sync_manager.rs @@ -194,8 +194,7 @@ impl BlockStore { highest_commit_cert: &'a QuorumCert, retriever: &'a mut BlockRetriever, storage: Arc, state_computer: Arc, - ) -> anyhow::Result - { + ) -> anyhow::Result { diem_debug!( LogSchema::new(LogEvent::StateSync) .remote_peer(retriever.preferred_peer), diff --git a/core/src/pos/consensus/block_storage/tracing.rs b/crates/cfxcore/core/src/pos/consensus/block_storage/tracing.rs similarity index 100% rename from core/src/pos/consensus/block_storage/tracing.rs rename to crates/cfxcore/core/src/pos/consensus/block_storage/tracing.rs diff --git a/core/src/pos/consensus/consensus-types/Cargo.toml b/crates/cfxcore/core/src/pos/consensus/consensus-types/Cargo.toml similarity index 100% rename from core/src/pos/consensus/consensus-types/Cargo.toml rename to crates/cfxcore/core/src/pos/consensus/consensus-types/Cargo.toml diff --git a/core/src/pos/consensus/consensus-types/src/block.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block.rs similarity index 99% rename from core/src/pos/consensus/consensus-types/src/block.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/block.rs index dd24aaa99f..9ce5d99a3c 100644 --- a/core/src/pos/consensus/consensus-types/src/block.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block.rs @@ -144,8 +144,7 @@ impl Block { &self, executed_state_id: HashValue, version: Version, next_epoch_state: Option, pivot: Option, - ) -> BlockInfo - { + ) -> BlockInfo { BlockInfo::new( self.epoch(), self.round(), @@ -195,8 +194,7 @@ impl Block { id: HashValue, block_data: BlockData, signature: Option, vrf_proof: Option<(u64, ConsensusVRFProof)>, - ) -> Self - { + ) -> Self { Block { id, block_data, @@ -223,8 +221,7 @@ impl Block { pub fn new_proposal( payload: Payload, round: Round, timestamp_usecs: u64, quorum_cert: QuorumCert, validator_signer: &ValidatorSigner, - ) -> Self - { + ) -> Self { let block_data = BlockData::new_proposal( payload, validator_signer.author(), @@ -249,8 +246,7 @@ impl Block { pub fn new_proposal_from_block_data_and_signature( block_data: BlockData, signature: ConsensusSignature, vrf_nonce_and_proof: Option<(u64, ConsensusVRFProof)>, - ) -> Self - { + ) -> Self { Block { id: block_data.hash(), block_data, diff --git a/core/src/pos/consensus/consensus-types/src/block_data.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_data.rs similarity index 99% rename from core/src/pos/consensus/consensus-types/src/block_data.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_data.rs index aad114ec01..dfc6752aa5 100644 --- a/core/src/pos/consensus/consensus-types/src/block_data.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_data.rs @@ -218,8 +218,7 @@ impl BlockData { pub fn new_for_testing( epoch: u64, round: Round, timestamp_usecs: u64, quorum_cert: QuorumCert, block_type: BlockType, - ) -> Self - { + ) -> Self { Self { epoch, round, @@ -261,8 +260,7 @@ impl BlockData { pub fn new_proposal( payload: Payload, author: Author, round: Round, timestamp_usecs: u64, quorum_cert: QuorumCert, - ) -> Self - { + ) -> Self { Self { epoch: quorum_cert.certified_block().epoch(), round, diff --git a/core/src/pos/consensus/consensus-types/src/block_retrieval.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_retrieval.rs similarity index 99% rename from core/src/pos/consensus/consensus-types/src/block_retrieval.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_retrieval.rs index 484ad55f2a..c3803e3617 100644 --- a/core/src/pos/consensus/consensus-types/src/block_retrieval.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_retrieval.rs @@ -75,8 +75,7 @@ impl BlockRetrievalResponse { pub fn verify( &self, block_id: HashValue, num_blocks: u64, sig_verifier: &ValidatorVerifier, - ) -> anyhow::Result<()> - { + ) -> anyhow::Result<()> { ensure!( self.status != BlockRetrievalStatus::Succeeded || (self.blocks.len() as u64 <= num_blocks diff --git a/core/src/pos/consensus/consensus-types/src/block_test.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_test.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/block_test.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_test.rs diff --git a/core/src/pos/consensus/consensus-types/src/block_test_utils.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_test_utils.rs similarity index 99% rename from core/src/pos/consensus/consensus-types/src/block_test_utils.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_test_utils.rs index 9cea482e0a..ee719258f1 100644 --- a/core/src/pos/consensus/consensus-types/src/block_test_utils.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/block_test_utils.rs @@ -186,8 +186,7 @@ pub fn placeholder_ledger_info() -> LedgerInfo { pub fn gen_test_certificate( signers: Vec<&ValidatorSigner>, block: BlockInfo, parent_block: BlockInfo, committed_block: Option, -) -> QuorumCert -{ +) -> QuorumCert { let vote_data = VoteData::new(block, parent_block); let ledger_info = match committed_block { Some(info) => LedgerInfo::new(info, vote_data.hash()), @@ -214,8 +213,7 @@ pub fn placeholder_certificate_for_block( signers: Vec<&ValidatorSigner>, certified_block_id: HashValue, certified_block_round: u64, certified_parent_block_id: HashValue, certified_parent_block_round: u64, -) -> QuorumCert -{ +) -> QuorumCert { // Assuming executed state to be Genesis state. let genesis_ledger_info = LedgerInfo::mock_genesis(None); let vote_data = VoteData::new( diff --git a/core/src/pos/consensus/consensus-types/src/common.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/common.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/common.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/common.rs diff --git a/core/src/pos/consensus/consensus-types/src/db.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/db.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/db.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/db.rs diff --git a/core/src/pos/consensus/consensus-types/src/epoch_retrieval.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/epoch_retrieval.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/epoch_retrieval.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/epoch_retrieval.rs diff --git a/core/src/pos/consensus/consensus-types/src/executed_block.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/executed_block.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/executed_block.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/executed_block.rs diff --git a/core/src/pos/consensus/consensus-types/src/lib.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/lib.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/lib.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/lib.rs diff --git a/core/src/pos/consensus/consensus-types/src/proposal_msg.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/proposal_msg.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/proposal_msg.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/proposal_msg.rs diff --git a/core/src/pos/consensus/consensus-types/src/quorum_cert.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/quorum_cert.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/quorum_cert.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/quorum_cert.rs diff --git a/core/src/pos/consensus/consensus-types/src/safety_data.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/safety_data.rs similarity index 98% rename from core/src/pos/consensus/consensus-types/src/safety_data.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/safety_data.rs index f6c7ff056b..1c263eb28d 100644 --- a/core/src/pos/consensus/consensus-types/src/safety_data.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/safety_data.rs @@ -22,8 +22,7 @@ impl SafetyData { pub fn new( epoch: u64, last_voted_round: u64, preferred_round: u64, last_vote: Option, - ) -> Self - { + ) -> Self { Self { epoch, last_voted_round, diff --git a/core/src/pos/consensus/consensus-types/src/sync_info.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/sync_info.rs similarity index 99% rename from core/src/pos/consensus/consensus-types/src/sync_info.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/sync_info.rs index 27947dc059..fc58e50a78 100644 --- a/core/src/pos/consensus/consensus-types/src/sync_info.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/sync_info.rs @@ -54,8 +54,7 @@ impl SyncInfo { pub fn new( highest_quorum_cert: QuorumCert, highest_commit_cert: QuorumCert, highest_timeout_cert: Option, - ) -> Self - { + ) -> Self { let commit_cert = if highest_quorum_cert == highest_commit_cert { None } else { diff --git a/core/src/pos/consensus/consensus-types/src/timeout.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/timeout.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/timeout.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/timeout.rs diff --git a/core/src/pos/consensus/consensus-types/src/timeout_certificate.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/timeout_certificate.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/timeout_certificate.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/timeout_certificate.rs diff --git a/core/src/pos/consensus/consensus-types/src/vote.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote.rs similarity index 99% rename from core/src/pos/consensus/consensus-types/src/vote.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote.rs index 0a1f9e63ee..3d11669e5d 100644 --- a/core/src/pos/consensus/consensus-types/src/vote.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote.rs @@ -64,8 +64,7 @@ impl Vote { vote_data: VoteData, author: Author, mut ledger_info_placeholder: LedgerInfo, validator_signer: &ValidatorSigner, - ) -> Self - { + ) -> Self { ledger_info_placeholder.set_consensus_data_hash(vote_data.hash()); let signature = validator_signer.sign(&ledger_info_placeholder); Self::new_with_signature( @@ -80,8 +79,7 @@ impl Vote { pub fn new_with_signature( vote_data: VoteData, author: Author, ledger_info: LedgerInfo, signature: ConsensusSignature, - ) -> Self - { + ) -> Self { Self { vote_data, author, diff --git a/core/src/pos/consensus/consensus-types/src/vote_data.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote_data.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/vote_data.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote_data.rs diff --git a/core/src/pos/consensus/consensus-types/src/vote_msg.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote_msg.rs similarity index 100% rename from core/src/pos/consensus/consensus-types/src/vote_msg.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote_msg.rs diff --git a/core/src/pos/consensus/consensus-types/src/vote_proposal.rs b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote_proposal.rs similarity index 99% rename from core/src/pos/consensus/consensus-types/src/vote_proposal.rs rename to crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote_proposal.rs index dc4c8e0cc3..a9e930a468 100644 --- a/core/src/pos/consensus/consensus-types/src/vote_proposal.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus-types/src/vote_proposal.rs @@ -42,8 +42,7 @@ impl VoteProposal { >, block: Block, next_epoch_state: Option, pivot_decision: Option, - ) -> Self - { + ) -> Self { Self { accumulator_extension_proof, block, diff --git a/core/src/pos/consensus/consensus_provider.rs b/crates/cfxcore/core/src/pos/consensus/consensus_provider.rs similarity index 97% rename from core/src/pos/consensus/consensus_provider.rs rename to crates/cfxcore/core/src/pos/consensus/consensus_provider.rs index 92b96a7b98..22719a6ab5 100644 --- a/core/src/pos/consensus/consensus_provider.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensus_provider.rs @@ -19,7 +19,7 @@ use diem_types::{ account_address::AccountAddress, on_chain_config::OnChainConfigPayload, transaction::SignedTransaction, }; -use executor::{vm::FakeVM, Executor}; +use executor::{vm::PosVM, Executor}; use storage_interface::DbReader; use crate::pos::{ @@ -53,8 +53,7 @@ pub fn start_consensus( )>, test_command_receiver: channel::Receiver, started_as_voter: bool, -) -> (Runtime, Arc, Arc, Arc) -{ +) -> (Runtime, Arc, Arc, Arc) { let stopped = Arc::new(AtomicBool::new(false)); let runtime = runtime::Builder::new_multi_thread() .thread_name("consensus") @@ -75,7 +74,7 @@ pub fn start_consensus( runtime.handle().clone(), consensus_db.clone(), )); - let executor = Box::new(Executor::::new( + let executor = Box::new(Executor::::new( db_with_cache, pow_handler.clone(), consensus_db.clone() as Arc, diff --git a/core/src/pos/consensus/consensusdb/consensusdb_test.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/consensusdb_test.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/consensusdb_test.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/consensusdb_test.rs diff --git a/core/src/pos/consensus/consensusdb/mod.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/mod.rs similarity index 99% rename from core/src/pos/consensus/consensusdb/mod.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/mod.rs index 43e1360ce9..bf44d6e765 100644 --- a/core/src/pos/consensus/consensusdb/mod.rs +++ b/crates/cfxcore/core/src/pos/consensus/consensusdb/mod.rs @@ -221,8 +221,7 @@ impl ConsensusDB { pub fn put_staking_events( &self, pow_epoch_number: u64, pow_epoch_hash: H256, events: Vec, - ) -> Result<(), DbError> - { + ) -> Result<(), DbError> { let mut batch = SchemaBatch::new(); batch.put::( &pow_epoch_number, @@ -235,8 +234,7 @@ impl ConsensusDB { pub fn get_staking_events( &self, parent_decision: PivotBlockDecision, me_decision: PivotBlockDecision, - ) -> Result, DbError> - { + ) -> Result, DbError> { diem_debug!( "consensusdb::get_staking_events: parent={:?} me={:?}", parent_decision, diff --git a/core/src/pos/consensus/consensusdb/schema/block/mod.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/block/mod.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/block/mod.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/block/mod.rs diff --git a/core/src/pos/consensus/consensusdb/schema/block/test.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/block/test.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/block/test.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/block/test.rs diff --git a/core/src/pos/consensus/consensusdb/schema/ledger_block/mod.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/ledger_block/mod.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/ledger_block/mod.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/ledger_block/mod.rs diff --git a/core/src/pos/consensus/consensusdb/schema/ledger_block/test.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/ledger_block/test.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/ledger_block/test.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/ledger_block/test.rs diff --git a/core/src/pos/consensus/consensusdb/schema/mod.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/mod.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/mod.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/mod.rs diff --git a/core/src/pos/consensus/consensusdb/schema/quorum_certificate/mod.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/quorum_certificate/mod.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/quorum_certificate/mod.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/quorum_certificate/mod.rs diff --git a/core/src/pos/consensus/consensusdb/schema/quorum_certificate/test.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/quorum_certificate/test.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/quorum_certificate/test.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/quorum_certificate/test.rs diff --git a/core/src/pos/consensus/consensusdb/schema/single_entry/mod.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/single_entry/mod.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/single_entry/mod.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/single_entry/mod.rs diff --git a/core/src/pos/consensus/consensusdb/schema/single_entry/test.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/single_entry/test.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/single_entry/test.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/single_entry/test.rs diff --git a/core/src/pos/consensus/consensusdb/schema/staking_event/mod.rs b/crates/cfxcore/core/src/pos/consensus/consensusdb/schema/staking_event/mod.rs similarity index 100% rename from core/src/pos/consensus/consensusdb/schema/staking_event/mod.rs rename to crates/cfxcore/core/src/pos/consensus/consensusdb/schema/staking_event/mod.rs diff --git a/core/src/pos/consensus/counters.rs b/crates/cfxcore/core/src/pos/consensus/counters.rs similarity index 100% rename from core/src/pos/consensus/counters.rs rename to crates/cfxcore/core/src/pos/consensus/counters.rs diff --git a/core/src/pos/consensus/epoch_manager.rs b/crates/cfxcore/core/src/pos/consensus/epoch_manager.rs similarity index 99% rename from core/src/pos/consensus/epoch_manager.rs rename to crates/cfxcore/core/src/pos/consensus/epoch_manager.rs index 653d257226..5d570894cc 100644 --- a/core/src/pos/consensus/epoch_manager.rs +++ b/crates/cfxcore/core/src/pos/consensus/epoch_manager.rs @@ -144,8 +144,7 @@ impl EpochManager { oneshot::Sender>, )>, started_as_voter: bool, - ) -> Self - { + ) -> Self { let config = node_config.consensus.clone(); let sr_config = &node_config.consensus.safety_rules; let safety_rules_manager = SafetyRulesManager::new(sr_config); @@ -190,8 +189,7 @@ impl EpochManager { timeout_sender: channel::Sender<(u64, Round)>, proposal_timeout_sender: channel::Sender<(u64, Round)>, new_round_timeout_sender: channel::Sender<(u64, Round)>, epoch: u64, - ) -> RoundState - { + ) -> RoundState { // 1.5^6 ~= 11 // Timeout goes from initial_timeout to initial_timeout*11 in 6 steps let base_interval = Duration::from_millis( @@ -503,8 +501,7 @@ impl EpochManager { async fn start_recovery_manager( &mut self, ledger_recovery_data: LedgerRecoveryData, epoch_state: EpochState, - ) - { + ) { let epoch = epoch_state.epoch; let network_sender = ConsensusNetworkSender::new( self.author, @@ -774,8 +771,7 @@ impl EpochManager { mut network_receivers: NetworkReceivers, mut test_command_receiver: channel::Receiver, stopped: Arc, - ) - { + ) { // initial start of the processor self.expect_new_epoch().await; diem_debug!("EpochManager main_loop starts"); @@ -937,8 +933,7 @@ impl EpochManager { async fn force_propose( &mut self, round: Round, parent_block_id: HashValue, payload: Vec, - ) -> anyhow::Result<()> - { + ) -> anyhow::Result<()> { let bls_key = self .config .safety_rules diff --git a/core/src/pos/consensus/error.rs b/crates/cfxcore/core/src/pos/consensus/error.rs similarity index 100% rename from core/src/pos/consensus/error.rs rename to crates/cfxcore/core/src/pos/consensus/error.rs diff --git a/core/src/pos/consensus/executor/Cargo.toml b/crates/cfxcore/core/src/pos/consensus/executor/Cargo.toml similarity index 89% rename from core/src/pos/consensus/executor/Cargo.toml rename to crates/cfxcore/core/src/pos/consensus/executor/Cargo.toml index 550896f740..3064f09f01 100644 --- a/core/src/pos/consensus/executor/Cargo.toml +++ b/crates/cfxcore/core/src/pos/consensus/executor/Cargo.toml @@ -17,7 +17,7 @@ once_cell = "1.7.2" serde_json = "1.0.64" serde = { version = "1.0.124", features = ["derive"] } -consensus-types = { path = "../../consensus/consensus-types"} +consensus-types = { path = "../consensus-types" } executor-types = { path = "../../types/executor-types" } bcs = "0.1.2" diem-crypto = { path = "../../crypto/crypto" } @@ -34,9 +34,9 @@ storage-interface = { path = "../../storage/storage-interface" } subscription-service = { path = "../../common/subscription-service" } proptest = { version = "1.0.0", optional = true } -pow-types = { path = "../../types/pow-types"} +pow-types = { path = "../../types/pow-types" } async-trait = "0.1" -cfx-types = {path = "../../../../../cfx_types"} +cfx-types = {path = "../../../../../../cfx_types" } futures = "0.3.12" [dev-dependencies] diff --git a/core/src/pos/consensus/executor/src/db_bootstrapper.rs b/crates/cfxcore/core/src/pos/consensus/executor/src/db_bootstrapper.rs similarity index 99% rename from core/src/pos/consensus/executor/src/db_bootstrapper.rs rename to crates/cfxcore/core/src/pos/consensus/executor/src/db_bootstrapper.rs index b9055d56de..e68236946c 100644 --- a/core/src/pos/consensus/executor/src/db_bootstrapper.rs +++ b/crates/cfxcore/core/src/pos/consensus/executor/src/db_bootstrapper.rs @@ -64,8 +64,7 @@ pub fn maybe_bootstrap( genesis_pivot_decision: Option, initial_seed: Vec, initial_nodes: Vec<(NodeID, u64)>, initial_committee: Vec<(AccountAddress, u64)>, -) -> Result -{ +) -> Result { let tree_state = db.reader.get_latest_tree_state()?; // if the waypoint is not targeted with the genesis txn, it may be either // already bootstrapped, or aiming for state sync to catch up. @@ -137,8 +136,7 @@ pub fn calculate_genesis( genesis_pivot_decision: Option, initial_seed: Vec, initial_nodes: Vec<(NodeID, u64)>, initial_committee: Vec<(AccountAddress, u64)>, -) -> Result> -{ +) -> Result> { // DB bootstrapper works on either an empty transaction accumulator or an // existing block chain. In the very extreme and sad situation of losing // quorum among validators, we refer to the second use case said above. diff --git a/core/src/pos/consensus/executor/src/lib.rs b/crates/cfxcore/core/src/pos/consensus/executor/src/lib.rs similarity index 99% rename from core/src/pos/consensus/executor/src/lib.rs rename to crates/cfxcore/core/src/pos/consensus/executor/src/lib.rs index 741a884f5f..a709337739 100644 --- a/core/src/pos/consensus/executor/src/lib.rs +++ b/crates/cfxcore/core/src/pos/consensus/executor/src/lib.rs @@ -104,8 +104,7 @@ where V: VMExecutor db_with_cache: Arc, pow_handler: Arc, consensus_db: Arc, - ) -> Self - { + ) -> Self { Self { db_with_cache, consensus_db, @@ -120,8 +119,7 @@ where V: VMExecutor verified_target_li: LedgerInfoWithSignatures, epoch_change_li: Option, new_output: &ProcessedVMOutput, - ) -> Result> - { + ) -> Result> { // If the chunk corresponds to the target LI, the target LI can be added // to storage. if verified_target_li.ledger_info().version() @@ -177,8 +175,7 @@ where V: VMExecutor fn verify_chunk( &self, txn_list_with_proof: TransactionListWithProof, verified_target_li: &LedgerInfoWithSignatures, - ) -> Result<(Vec, Vec)> - { + ) -> Result<(Vec, Vec)> { // 1. Verify that input transactions belongs to the ledger represented // by the ledger info. txn_list_with_proof.verify( @@ -281,8 +278,7 @@ where V: VMExecutor transactions: &[Transaction], vm_outputs: Vec, parent_trees: &ExecutedTrees, parent_block_id: &HashValue, catch_up_mode: bool, - ) -> Result - { + ) -> Result { // The data of each individual transaction. For convenience purpose, // even for the transactions that will be discarded, we will // compute its in-memory Sparse Merkle Tree (it will be @@ -684,8 +680,7 @@ where V: VMExecutor Vec, Vec, Vec, - )> - { + )> { // Construct a StateView and pass the transactions to VM. let cache = self.db_with_cache.cache.lock(); let state_view = VerifiedStateView::new( @@ -793,8 +788,7 @@ where V: VMExecutor ProcessedVMOutput, Vec, Vec, - )> - { + )> { let num_txns = transactions.len(); let ( @@ -833,8 +827,7 @@ impl ChunkExecutor for Executor { // An optional end of epoch LedgerInfo. We do not allow chunks that end // epoch without carrying any epoch change LI. epoch_change_li: Option, - ) -> Result> - { + ) -> Result> { let _timer = DIEM_EXECUTOR_EXECUTE_AND_COMMIT_CHUNK_SECONDS.start_timer(); // 1. Update the cache in executor to be consistent with latest synced @@ -928,8 +921,7 @@ impl TransactionReplayer for Executor { fn replay_chunk( &self, mut first_version: Version, mut txns: Vec, mut txn_infos: Vec, - ) -> Result<()> - { + ) -> Result<()> { ensure!( first_version == self @@ -992,8 +984,7 @@ impl BlockExecutor for Executor { fn execute_block( &self, block: (HashValue, Vec), parent_block_id: HashValue, catch_up_mode: bool, - ) -> Result - { + ) -> Result { let (block_id, mut transactions) = block; // Reconfiguration rule - if a block is a child of pending @@ -1122,8 +1113,7 @@ impl BlockExecutor for Executor { fn commit_blocks( &self, block_ids: Vec, ledger_info_with_sigs: LedgerInfoWithSignatures, - ) -> Result<(Vec, Vec), Error> - { + ) -> Result<(Vec, Vec), Error> { let _timer = DIEM_EXECUTOR_COMMIT_BLOCKS_SECONDS.start_timer(); let mut pos_state_to_commit = self .get_executed_trees( @@ -1511,8 +1501,7 @@ pub fn process_write_set( transaction: &Transaction, account_to_state: &mut HashMap, write_set: WriteSet, -) -> Result> -{ +) -> Result> { let mut updated_blobs = HashMap::new(); // Find all addresses this transaction touches while processing each write diff --git a/core/src/pos/consensus/executor/src/logging.rs b/crates/cfxcore/core/src/pos/consensus/executor/src/logging.rs similarity index 100% rename from core/src/pos/consensus/executor/src/logging.rs rename to crates/cfxcore/core/src/pos/consensus/executor/src/logging.rs diff --git a/core/src/pos/consensus/executor/src/metrics.rs b/crates/cfxcore/core/src/pos/consensus/executor/src/metrics.rs similarity index 100% rename from core/src/pos/consensus/executor/src/metrics.rs rename to crates/cfxcore/core/src/pos/consensus/executor/src/metrics.rs diff --git a/crates/cfxcore/core/src/pos/consensus/executor/src/vm.rs b/crates/cfxcore/core/src/pos/consensus/executor/src/vm.rs new file mode 100644 index 0000000000..31c0b1d483 --- /dev/null +++ b/crates/cfxcore/core/src/pos/consensus/executor/src/vm.rs @@ -0,0 +1,369 @@ +use std::collections::BTreeMap; + +use consensus_types::{block::Block, vote::Vote}; +use diem_logger::{error as diem_error, prelude::*}; +use diem_state_view::StateView; +use diem_types::{ + account_address::from_consensus_public_key, + block_info::PivotBlockDecision, + contract_event::ContractEvent, + epoch_state::EpochState, + on_chain_config::{self, new_epoch_event_key, OnChainConfig, ValidatorSet}, + term_state::pos_state_config::{PosStateConfigTrait, POS_STATE_CONFIG}, + transaction::{ + authenticator::TransactionAuthenticator, ConflictSignature, + DisputePayload, ElectionPayload, RegisterPayload, RetirePayload, + SignatureCheckedTransaction, SignedTransaction, Transaction, + TransactionOutput, TransactionPayload, TransactionStatus, + UpdateVotingPowerPayload, WriteSetPayload, + }, + validator_verifier::{ValidatorConsensusInfo, ValidatorVerifier}, + vm_status::{KeptVMStatus, StatusCode, VMStatus}, + write_set::{WriteOp, WriteSetMut}, +}; + +/// This trait describes the VM's execution interface. +pub trait VMExecutor: Send { + // NOTE: At the moment there are no persistent caches that live past the end + // of a block (that's why execute_block doesn't take &self.) + // There are some cache invalidation issues around transactions publishing + // code that need to be sorted out before that's possible. + + /// Executes a block of transactions and returns output for each one of + /// them. + fn execute_block( + transactions: Vec, state_view: &dyn StateView, + catch_up_mode: bool, + ) -> Result, VMStatus>; +} + +/// A VM for Conflux PoS chain. +pub struct PosVM; + +impl VMExecutor for PosVM { + fn execute_block( + transactions: Vec, state_view: &dyn StateView, + catch_up_mode: bool, + ) -> Result, VMStatus> { + let mut vm_outputs = Vec::new(); + for transaction in transactions { + let output = match transaction { + Transaction::BlockMetadata(_) => { + Self::process_block_metadata(state_view)? + } + Transaction::UserTransaction(trans) => { + let tx = Self::check_signature_for_user_tx(trans)?; + let spec = Spec { catch_up_mode }; + Self::process_user_transaction(state_view, &tx, &spec)? + } + Transaction::GenesisTransaction(change_set) => { + Self::process_genesis_transction(&change_set)? + } + }; + vm_outputs.push(output); + } + + Ok(vm_outputs) + } +} + +impl PosVM { + fn process_block_metadata( + state_view: &dyn StateView, + ) -> Result { + let mut events = state_view.pos_state().get_unlock_events(); + diem_debug!("get_unlock_events: {}", events.len()); + + let next_view = state_view.pos_state().current_view() + 1; + let round_per_term = POS_STATE_CONFIG.round_per_term(); + + // TODO(lpl): Simplify. + if next_view % round_per_term == 0 { + let term = next_view / round_per_term; + let (validator_verifier, vrf_seed) = + state_view.pos_state().get_committee_at(term).map_err(|e| { + diem_warn!("get_new_committee error: {:?}", e); + VMStatus::Error(StatusCode::CFX_INVALID_TX) + })?; + let epoch = next_view / round_per_term + 1; + let validator_bytes = bcs::to_bytes(&EpochState::new( + epoch, + validator_verifier, + vrf_seed, + )) + .unwrap(); + let contract_event = + ContractEvent::new(new_epoch_event_key(), validator_bytes); + events.push(contract_event); + } + Ok(Self::gen_output(events, false)) + } + + fn check_signature_for_user_tx( + trans: SignedTransaction, + ) -> Result { + // TODO(lpl): Parallel verification. + trans.check_signature().map_err(|e| { + diem_trace!("invalid transactions signature: e={:?}", e); + VMStatus::Error(StatusCode::INVALID_SIGNATURE) + }) + } + + fn process_user_transaction( + state_view: &dyn StateView, tx: &SignatureCheckedTransaction, + spec: &Spec, + ) -> Result { + let events = match tx.payload() { + TransactionPayload::WriteSet(WriteSetPayload::Direct( + change_set, + )) => change_set.events().to_vec(), + TransactionPayload::Election(election_payload) => { + election_payload.execute(state_view, tx, spec)? + } + TransactionPayload::Retire(retire_payload) => { + retire_payload.execute(state_view, tx, spec)? + } + TransactionPayload::PivotDecision(pivot_decision) => { + pivot_decision.execute(state_view, tx, spec)? + } + TransactionPayload::Register(register) => { + register.execute(state_view, tx, spec)? + } + TransactionPayload::UpdateVotingPower(update) => { + update.execute(state_view, tx, spec)? + } + TransactionPayload::Dispute(dispute) => { + dispute.execute(state_view, tx, spec)? + } + _ => return Err(VMStatus::Error(StatusCode::CFX_UNEXPECTED_TX)), + }; + + Ok(Self::gen_output(events, false)) + } + + fn process_genesis_transction( + change_set: &WriteSetPayload, + ) -> Result { + let events = match change_set { + WriteSetPayload::Direct(change_set) => change_set.events().to_vec(), + _ => return Err(VMStatus::Error(StatusCode::CFX_UNEXPECTED_TX)), + }; + + Ok(Self::gen_output(events, true)) + } + + fn gen_output( + events: Vec, record_events_on_state: bool, + ) -> TransactionOutput { + let new_epoch_event_key = on_chain_config::new_epoch_event_key(); + let status = TransactionStatus::Keep(KeptVMStatus::Executed); + let mut write_set = WriteSetMut::default(); + + // TODO(linxi): support other event key + if record_events_on_state { + for event in &events { + if *event.key() == new_epoch_event_key { + write_set.push(( + ValidatorSet::CONFIG_ID.access_path(), + WriteOp::Value(event.event_data().to_vec()), + )); + } + } + } + + TransactionOutput::new(write_set.freeze().unwrap(), events, 0, status) + } +} + +pub struct Spec { + pub catch_up_mode: bool, +} + +pub trait ExecutableBuiltinTx { + fn execute( + &self, state_view: &dyn StateView, tx: &SignatureCheckedTransaction, + spec: &Spec, + ) -> Result, VMStatus>; +} + +impl ExecutableBuiltinTx for ElectionPayload { + fn execute( + &self, state_view: &dyn StateView, _tx: &SignatureCheckedTransaction, + spec: &Spec, + ) -> Result, VMStatus> { + if !spec.catch_up_mode { + state_view + .pos_state() + .validate_election(self) + .map_err(|e| { + diem_error!("election tx error: {:?}", e); + VMStatus::Error(StatusCode::CFX_INVALID_TX) + })?; + } + Ok(vec![self.to_event()]) + } +} + +impl ExecutableBuiltinTx for PivotBlockDecision { + fn execute( + &self, state_view: &dyn StateView, tx: &SignatureCheckedTransaction, + spec: &Spec, + ) -> Result, VMStatus> { + if !spec.catch_up_mode { + let authenticator = tx.authenticator(); + let signature = match authenticator { + TransactionAuthenticator::MultiBLS { signature } => { + Ok(signature) + } + _ => Err(VMStatus::Error(StatusCode::CFX_INVALID_TX)), + }?; + state_view + .pos_state() + .validate_pivot_decision(self, signature) + .map_err(|e| { + diem_error!("pivot decision tx error: {:?}", e); + VMStatus::Error(StatusCode::CFX_INVALID_TX) + })?; + } + Ok(vec![self.to_event()]) + } +} + +impl ExecutableBuiltinTx for DisputePayload { + fn execute( + &self, state_view: &dyn StateView, _tx: &SignatureCheckedTransaction, + _spec: &Spec, + ) -> Result, VMStatus> { + state_view.pos_state().validate_dispute(self).map_err(|e| { + diem_error!("dispute tx error: {:?}", e); + VMStatus::Error(StatusCode::CFX_INVALID_TX) + })?; + if !verify_dispute(self) { + return Err(VMStatus::Error(StatusCode::CFX_INVALID_TX)); + } + Ok(vec![self.to_event()]) + } +} + +macro_rules! impl_builtin_tx_by_gen_events { + ( $($name:ident),* ) => { + $(impl ExecutableBuiltinTx for $name { + fn execute(&self, _state_view: &dyn StateView,_tx: &SignatureCheckedTransaction, _spec: &Spec) -> Result, VMStatus> { + Ok(vec![self.to_event()]) + } + })* + } +} + +// Transactions which just generate events without other process +impl_builtin_tx_by_gen_events!( + RegisterPayload, + RetirePayload, + UpdateVotingPowerPayload +); + +/// Return true if the dispute is valid. +/// Return false if the encoding is invalid or the provided signatures are +/// not from the same round. +pub fn verify_dispute(dispute: &DisputePayload) -> bool { + let computed_address = + from_consensus_public_key(&dispute.bls_pub_key, &dispute.vrf_pub_key); + if dispute.address != computed_address { + diem_trace!("Incorrect address and public keys"); + return false; + } + match &dispute.conflicting_votes { + ConflictSignature::Proposal((proposal_byte1, proposal_byte2)) => { + let proposal1: Block = + match bcs::from_bytes(proposal_byte1.as_slice()) { + Ok(proposal) => proposal, + Err(e) => { + diem_trace!("1st proposal encoding error: {:?}", e); + return false; + } + }; + let proposal2: Block = + match bcs::from_bytes(proposal_byte2.as_slice()) { + Ok(proposal) => proposal, + Err(e) => { + diem_trace!("2nd proposal encoding error: {:?}", e); + return false; + } + }; + if proposal1 == proposal2 { + diem_trace!( + "Two same proposals are claimed to be conflict" + ); + return false; + } + if (proposal1.block_data().epoch() + != proposal2.block_data().epoch()) + || (proposal1.block_data().round() + != proposal2.block_data().round()) + { + diem_trace!("Two proposals are from different rounds"); + return false; + } + let mut temp_map = BTreeMap::new(); + temp_map.insert( + dispute.address, + ValidatorConsensusInfo::new( + dispute.bls_pub_key.clone(), + Some(dispute.vrf_pub_key.clone()), + 1, + ), + ); + let temp_verifier = ValidatorVerifier::new(temp_map); + if proposal1.validate_signature(&temp_verifier).is_err() + || proposal2.validate_signature(&temp_verifier).is_err() + { + return false; + } + } + ConflictSignature::Vote((vote_byte1, vote_byte2)) => { + let vote1: Vote = match bcs::from_bytes(vote_byte1.as_slice()) { + Ok(vote) => vote, + Err(e) => { + diem_trace!("1st vote encoding error: {:?}", e); + return false; + } + }; + let vote2: Vote = match bcs::from_bytes(vote_byte2.as_slice()) { + Ok(vote) => vote, + Err(e) => { + diem_trace!("2nd vote encoding error: {:?}", e); + return false; + } + }; + if vote1 == vote2 { + diem_trace!("Two same votes are claimed to be conflict"); + return false; + } + if (vote1.vote_data().proposed().epoch() + != vote2.vote_data().proposed().epoch()) + || (vote1.vote_data().proposed().round() + != vote2.vote_data().proposed().round()) + { + diem_trace!("Two votes are from different rounds"); + return false; + } + let mut temp_map = BTreeMap::new(); + temp_map.insert( + dispute.address, + ValidatorConsensusInfo::new( + dispute.bls_pub_key.clone(), + Some(dispute.vrf_pub_key.clone()), + 1, + ), + ); + let temp_verifier = ValidatorVerifier::new(temp_map); + if vote1.verify(&temp_verifier).is_err() + || vote2.verify(&temp_verifier).is_err() + { + diem_trace!("dispute vote verification error: vote1_r={:?} vote2_r={:?}", vote1.verify(&temp_verifier), vote2.verify(&temp_verifier)); + return false; + } + } + } + true +} diff --git a/core/src/pos/consensus/liveness/mod.rs b/crates/cfxcore/core/src/pos/consensus/liveness/mod.rs similarity index 100% rename from core/src/pos/consensus/liveness/mod.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/mod.rs diff --git a/core/src/pos/consensus/liveness/proposal_generator.rs b/crates/cfxcore/core/src/pos/consensus/liveness/proposal_generator.rs similarity index 99% rename from core/src/pos/consensus/liveness/proposal_generator.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/proposal_generator.rs index 0998497c0b..edd755e5d6 100644 --- a/core/src/pos/consensus/liveness/proposal_generator.rs +++ b/crates/cfxcore/core/src/pos/consensus/liveness/proposal_generator.rs @@ -77,8 +77,7 @@ impl ProposalGenerator { private_key: ConsensusPrivateKey, public_key: ConsensusPublicKey, vrf_private_key: ConsensusVRFPrivateKey, vrf_public_key: ConsensusVRFPublicKey, - ) -> Self - { + ) -> Self { Self { author, block_store, @@ -298,8 +297,7 @@ impl ProposalGenerator { pub fn force_propose( &self, round: Round, parent_qc: Arc, payload: Vec, - ) -> anyhow::Result - { + ) -> anyhow::Result { let payload = payload .into_iter() .map(|p| { diff --git a/core/src/pos/consensus/liveness/proposal_generator_test.rs b/crates/cfxcore/core/src/pos/consensus/liveness/proposal_generator_test.rs similarity index 100% rename from core/src/pos/consensus/liveness/proposal_generator_test.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/proposal_generator_test.rs diff --git a/core/src/pos/consensus/liveness/proposer_election.rs b/crates/cfxcore/core/src/pos/consensus/liveness/proposer_election.rs similarity index 100% rename from core/src/pos/consensus/liveness/proposer_election.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/proposer_election.rs diff --git a/core/src/pos/consensus/liveness/rotating_proposer_election.rs b/crates/cfxcore/core/src/pos/consensus/liveness/rotating_proposer_election.rs similarity index 100% rename from core/src/pos/consensus/liveness/rotating_proposer_election.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/rotating_proposer_election.rs diff --git a/core/src/pos/consensus/liveness/rotating_proposer_test.rs b/crates/cfxcore/core/src/pos/consensus/liveness/rotating_proposer_test.rs similarity index 100% rename from core/src/pos/consensus/liveness/rotating_proposer_test.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/rotating_proposer_test.rs diff --git a/core/src/pos/consensus/liveness/round_proposer_election.rs b/crates/cfxcore/core/src/pos/consensus/liveness/round_proposer_election.rs similarity index 100% rename from core/src/pos/consensus/liveness/round_proposer_election.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/round_proposer_election.rs diff --git a/core/src/pos/consensus/liveness/round_proposer_test.rs b/crates/cfxcore/core/src/pos/consensus/liveness/round_proposer_test.rs similarity index 100% rename from core/src/pos/consensus/liveness/round_proposer_test.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/round_proposer_test.rs diff --git a/core/src/pos/consensus/liveness/round_state.rs b/crates/cfxcore/core/src/pos/consensus/liveness/round_state.rs similarity index 99% rename from core/src/pos/consensus/liveness/round_state.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/round_state.rs index 6ca6d84788..5201d745bf 100644 --- a/core/src/pos/consensus/liveness/round_state.rs +++ b/crates/cfxcore/core/src/pos/consensus/liveness/round_state.rs @@ -209,8 +209,7 @@ impl RoundState { timeout_sender: channel::Sender<(u64, Round)>, proposal_timeout_sender: channel::Sender<(u64, Round)>, new_round_timeout_sender: channel::Sender<(u64, Round)>, - ) -> Self - { + ) -> Self { // Our counters are initialized lazily, so they're not going to appear // in Prometheus if some conditions never happen. Invoking get() // function enforces creation. diff --git a/core/src/pos/consensus/liveness/round_state_test.rs b/crates/cfxcore/core/src/pos/consensus/liveness/round_state_test.rs similarity index 100% rename from core/src/pos/consensus/liveness/round_state_test.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/round_state_test.rs diff --git a/core/src/pos/consensus/liveness/vrf_proposer_election.rs b/crates/cfxcore/core/src/pos/consensus/liveness/vrf_proposer_election.rs similarity index 99% rename from core/src/pos/consensus/liveness/vrf_proposer_election.rs rename to crates/cfxcore/core/src/pos/consensus/liveness/vrf_proposer_election.rs index fbfa7fcab7..97e9472a9f 100644 --- a/core/src/pos/consensus/liveness/vrf_proposer_election.rs +++ b/crates/cfxcore/core/src/pos/consensus/liveness/vrf_proposer_election.rs @@ -37,8 +37,7 @@ impl VrfProposer { pub fn new( author: Author, vrf_private_key: ConsensusVRFPrivateKey, proposal_threshold_u256: U256, epoch_state: EpochState, - ) -> Self - { + ) -> Self { let mut proposal_threshold = [0 as u8; HashValue::LENGTH]; proposal_threshold_u256.to_big_endian(&mut proposal_threshold); Self { diff --git a/core/src/pos/consensus/logging.rs b/crates/cfxcore/core/src/pos/consensus/logging.rs similarity index 100% rename from core/src/pos/consensus/logging.rs rename to crates/cfxcore/core/src/pos/consensus/logging.rs diff --git a/core/src/pos/consensus/metrics_safety_rules.rs b/crates/cfxcore/core/src/pos/consensus/metrics_safety_rules.rs similarity index 99% rename from core/src/pos/consensus/metrics_safety_rules.rs rename to crates/cfxcore/core/src/pos/consensus/metrics_safety_rules.rs index 676f493530..5043efd67d 100644 --- a/core/src/pos/consensus/metrics_safety_rules.rs +++ b/crates/cfxcore/core/src/pos/consensus/metrics_safety_rules.rs @@ -27,8 +27,7 @@ impl MetricsSafetyRules { pub fn new( inner: Box, storage: Arc, - ) -> Self - { + ) -> Self { Self { inner, storage } } diff --git a/core/src/pos/consensus/mod.rs b/crates/cfxcore/core/src/pos/consensus/mod.rs similarity index 100% rename from core/src/pos/consensus/mod.rs rename to crates/cfxcore/core/src/pos/consensus/mod.rs diff --git a/core/src/pos/consensus/network.rs b/crates/cfxcore/core/src/pos/consensus/network.rs similarity index 99% rename from core/src/pos/consensus/network.rs rename to crates/cfxcore/core/src/pos/consensus/network.rs index c81776f53d..f848ed1295 100644 --- a/core/src/pos/consensus/network.rs +++ b/crates/cfxcore/core/src/pos/consensus/network.rs @@ -98,8 +98,7 @@ impl ConsensusNetworkSender { pub fn new( author: Author, network_sender: NetworkSender, validators: ValidatorVerifier, - ) -> Self - { + ) -> Self { ConsensusNetworkSender { author, network_sender, @@ -115,8 +114,7 @@ impl ConsensusNetworkSender { pub async fn request_block( &mut self, retrieval_request: BlockRetrievalRequest, from: Author, timeout: Duration, - ) -> anyhow::Result - { + ) -> anyhow::Result { ensure!(from != self.author, "Retrieve block from self"); let peer_hash = self diff --git a/core/src/pos/consensus/network_tests.rs b/crates/cfxcore/core/src/pos/consensus/network_tests.rs similarity index 100% rename from core/src/pos/consensus/network_tests.rs rename to crates/cfxcore/core/src/pos/consensus/network_tests.rs diff --git a/core/src/pos/consensus/pending_votes.rs b/crates/cfxcore/core/src/pos/consensus/pending_votes.rs similarity index 100% rename from core/src/pos/consensus/pending_votes.rs rename to crates/cfxcore/core/src/pos/consensus/pending_votes.rs diff --git a/core/src/pos/consensus/persistent_liveness_storage.rs b/crates/cfxcore/core/src/pos/consensus/persistent_liveness_storage.rs similarity index 99% rename from core/src/pos/consensus/persistent_liveness_storage.rs rename to crates/cfxcore/core/src/pos/consensus/persistent_liveness_storage.rs index 3c440f51f5..9006d31006 100644 --- a/core/src/pos/consensus/persistent_liveness_storage.rs +++ b/crates/cfxcore/core/src/pos/consensus/persistent_liveness_storage.rs @@ -169,8 +169,7 @@ impl RootMetadata { num_leaves: u64, accu_hash: HashValue, frozen_root_hashes: Vec, pivot_decision: Option, - ) -> Self - { + ) -> Self { Self { num_leaves, accu_hash, @@ -216,8 +215,7 @@ impl RecoveryData { mut blocks: Vec, root_metadata: RootMetadata, mut quorum_certs: Vec, highest_timeout_certificate: Option, - ) -> Result - { + ) -> Result { let root = ledger_recovery_data .find_root(&mut blocks, &mut quorum_certs) .with_context(|| { @@ -288,8 +286,7 @@ impl RecoveryData { fn find_blocks_to_prune( root_id: HashValue, blocks: &mut Vec, quorum_certs: &mut Vec, - ) -> Vec - { + ) -> Vec { // prune all the blocks that don't have root as ancestor let mut tree = HashSet::new(); let mut to_remove = vec![]; diff --git a/core/src/pos/consensus/round_manager.rs b/crates/cfxcore/core/src/pos/consensus/round_manager.rs similarity index 99% rename from core/src/pos/consensus/round_manager.rs rename to crates/cfxcore/core/src/pos/consensus/round_manager.rs index 3bbca74eb0..07da2fbcba 100644 --- a/core/src/pos/consensus/round_manager.rs +++ b/crates/cfxcore/core/src/pos/consensus/round_manager.rs @@ -157,8 +157,7 @@ impl RecoveryManager { epoch_state: EpochState, network: ConsensusNetworkSender, storage: Arc, state_computer: Arc, last_committed_round: Round, - ) -> Self - { + ) -> Self { RecoveryManager { epoch_state, network, @@ -258,8 +257,7 @@ impl RoundManager { chain_id: ChainId, is_voting: bool, election_control: Arc, consensus_private_key: Option>, vrf_private_key: Option>, - ) -> Self - { + ) -> Self { counters::OP_COUNTERS .gauge("sync_only") .set(sync_only as i64); @@ -639,8 +637,7 @@ impl RoundManager { pub async fn sync_to_ledger_info( &mut self, ledger_info: &LedgerInfoWithSignatures, peer_id: AccountAddress, - ) -> Result<()> - { + ) -> Result<()> { diem_debug!("sync_to_ledger_info: {:?}", ledger_info); let mut retriever = self.create_block_retriever(peer_id); if !self @@ -680,8 +677,7 @@ impl RoundManager { pub async fn ensure_round_and_sync_up( &mut self, message_round: Round, sync_info: &SyncInfo, author: Author, help_remote: bool, - ) -> anyhow::Result - { + ) -> anyhow::Result { if message_round < self.round_state.current_round() { return Ok(false); } @@ -1319,8 +1315,7 @@ impl RoundManager { pub async fn force_vote_proposal( &mut self, block_id: HashValue, author: Author, private_key: &ConsensusPrivateKey, - ) -> Result<()> - { + ) -> Result<()> { let proposal = self .block_store .get_block(block_id) @@ -1352,8 +1347,7 @@ impl RoundManager { pub async fn force_propose( &mut self, round: Round, parent_block_id: HashValue, payload: Vec, private_key: &ConsensusPrivateKey, - ) -> Result<()> - { + ) -> Result<()> { let parent_qc = self .block_store .get_quorum_cert_for_block(parent_block_id) diff --git a/core/src/pos/consensus/round_manager_fuzzing.rs b/crates/cfxcore/core/src/pos/consensus/round_manager_fuzzing.rs similarity index 100% rename from core/src/pos/consensus/round_manager_fuzzing.rs rename to crates/cfxcore/core/src/pos/consensus/round_manager_fuzzing.rs diff --git a/core/src/pos/consensus/round_manager_test.rs b/crates/cfxcore/core/src/pos/consensus/round_manager_test.rs similarity index 100% rename from core/src/pos/consensus/round_manager_test.rs rename to crates/cfxcore/core/src/pos/consensus/round_manager_test.rs diff --git a/core/src/pos/consensus/safety-rules/Cargo.toml b/crates/cfxcore/core/src/pos/consensus/safety-rules/Cargo.toml similarity index 99% rename from core/src/pos/consensus/safety-rules/Cargo.toml rename to crates/cfxcore/core/src/pos/consensus/safety-rules/Cargo.toml index 4a4ddf008e..013827c2e4 100644 --- a/core/src/pos/consensus/safety-rules/Cargo.toml +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/Cargo.toml @@ -17,7 +17,7 @@ consensus-types = { path = "../consensus-types" } bcs = "0.1.2" diem-config = { path = "../../config" } diem-crypto = { path = "../../crypto/crypto" } -diem-global-constants = { path = "../../config/global-constants"} +diem-global-constants = { path = "../../config/global-constants" } diem-infallible = { path = "../../common/infallible" } diem-logger = { path = "../../common/logger" } diem-proptest-helpers = { path = "../../common/proptest-helpers", optional = true } diff --git a/core/src/pos/consensus/safety-rules/benches/safety_rules.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/benches/safety_rules.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/benches/safety_rules.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/benches/safety_rules.rs diff --git a/core/src/pos/consensus/safety-rules/src/configurable_validator_signer.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/configurable_validator_signer.rs similarity index 99% rename from core/src/pos/consensus/safety-rules/src/configurable_validator_signer.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/configurable_validator_signer.rs index 698afe5439..a0b21d8386 100644 --- a/core/src/pos/consensus/safety-rules/src/configurable_validator_signer.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/configurable_validator_signer.rs @@ -34,8 +34,7 @@ impl ConfigurableValidatorSigner { pub fn new_signer( author: AccountAddress, consensus_key: ConsensusPrivateKey, vrf_private_key: Option, - ) -> Self - { + ) -> Self { let signer = ValidatorSigner::new(author, consensus_key, vrf_private_key); ConfigurableValidatorSigner::Signer(signer) diff --git a/core/src/pos/consensus/safety-rules/src/consensus_state.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/consensus_state.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/consensus_state.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/consensus_state.rs diff --git a/core/src/pos/consensus/safety-rules/src/counters.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/counters.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/counters.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/counters.rs diff --git a/core/src/pos/consensus/safety-rules/src/error.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/error.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/error.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/error.rs diff --git a/core/src/pos/consensus/safety-rules/src/fuzzing_utils.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/fuzzing_utils.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/fuzzing_utils.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/fuzzing_utils.rs diff --git a/core/src/pos/consensus/safety-rules/src/lib.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/lib.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/lib.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/lib.rs diff --git a/core/src/pos/consensus/safety-rules/src/local_client.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/local_client.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/local_client.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/local_client.rs diff --git a/core/src/pos/consensus/safety-rules/src/logging.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/logging.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/logging.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/logging.rs diff --git a/core/src/pos/consensus/safety-rules/src/main.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/main.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/main.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/main.rs diff --git a/core/src/pos/consensus/safety-rules/src/persistent_safety_storage.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/persistent_safety_storage.rs similarity index 99% rename from core/src/pos/consensus/safety-rules/src/persistent_safety_storage.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/persistent_safety_storage.rs index 339f8e6387..c1692c2c5b 100644 --- a/core/src/pos/consensus/safety-rules/src/persistent_safety_storage.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/persistent_safety_storage.rs @@ -52,8 +52,7 @@ impl PersistentSafetyStorage { mut internal_store: Storage, author: Author, private_key: ConsensusPrivateKey, waypoint: Waypoint, enable_cached_safety_data: bool, - ) -> Self - { + ) -> Self { let geneisis_safety_data = SafetyData::new(1, 0, 0, None); let safety_data = Self::initialize_( &mut internal_store, @@ -132,8 +131,7 @@ impl PersistentSafetyStorage { fn initialize_( internal_store: &mut Storage, safety_data: SafetyData, author: Author, waypoint: Waypoint, - ) -> Result - { + ) -> Result { // Attempting to re-initialize existing storage. This can happen in // environments like cluster test. Rather than be rigid here, // leave it up to the developer to detect inconsistencies or why diff --git a/core/src/pos/consensus/safety-rules/src/process.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/process.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/process.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/process.rs diff --git a/core/src/pos/consensus/safety-rules/src/remote_service.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/remote_service.rs similarity index 99% rename from core/src/pos/consensus/safety-rules/src/remote_service.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/remote_service.rs index 032bb834da..8fd6cf569c 100644 --- a/core/src/pos/consensus/safety-rules/src/remote_service.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/remote_service.rs @@ -39,8 +39,7 @@ pub fn execute( storage: PersistentSafetyStorage, listen_addr: SocketAddr, verify_vote_proposal_signature: bool, export_consensus_key: bool, network_timeout_ms: u64, vrf_private_key: Option, -) -{ +) { let mut safety_rules = SafetyRules::new( storage, verify_vote_proposal_signature, @@ -68,8 +67,7 @@ pub fn execute( fn process_one_message( network_server: &mut NetworkServer, serializer_service: &mut SerializerService, -) -> Result<(), Error> -{ +) -> Result<(), Error> { let request = network_server.read()?; let response = serializer_service.handle_message(request)?; network_server.write(&response)?; diff --git a/core/src/pos/consensus/safety-rules/src/safety_rules.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/safety_rules.rs similarity index 99% rename from core/src/pos/consensus/safety-rules/src/safety_rules.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/safety_rules.rs index 050003696a..aaafc52673 100644 --- a/core/src/pos/consensus/safety-rules/src/safety_rules.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/safety_rules.rs @@ -66,8 +66,7 @@ impl SafetyRules { _verify_vote_proposal_signature: bool, export_consensus_key: bool, vrf_private_key: Option, author: AccountAddress, - ) -> Self - { + ) -> Self { let execution_public_key = None; if let Ok(storage_author) = persistent_storage.author() { if storage_author != author { diff --git a/core/src/pos/consensus/safety-rules/src/safety_rules_manager.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/safety_rules_manager.rs similarity index 99% rename from core/src/pos/consensus/safety-rules/src/safety_rules_manager.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/safety_rules_manager.rs index f9109db2c7..9cadeb8dd0 100644 --- a/core/src/pos/consensus/safety-rules/src/safety_rules_manager.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/safety_rules_manager.rs @@ -113,8 +113,7 @@ impl SafetyRulesManager { export_consensus_key: bool, vrf_private_key: Option, author: AccountAddress, - ) -> Self - { + ) -> Self { let safety_rules = SafetyRules::new( storage, verify_vote_proposal_signature, @@ -139,8 +138,7 @@ impl SafetyRulesManager { pub fn new_serializer( storage: PersistentSafetyStorage, verify_vote_proposal_signature: bool, export_consensus_key: bool, author: AccountAddress, - ) -> Self - { + ) -> Self { let safety_rules = SafetyRules::new( storage, verify_vote_proposal_signature, @@ -160,8 +158,7 @@ impl SafetyRulesManager { pub fn new_thread( storage: PersistentSafetyStorage, verify_vote_proposal_signature: bool, export_consensus_key: bool, timeout_ms: u64, - ) -> Self - { + ) -> Self { let thread = ThreadService::new( storage, verify_vote_proposal_signature, diff --git a/core/src/pos/consensus/safety-rules/src/serializer.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/serializer.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/serializer.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/serializer.rs diff --git a/core/src/pos/consensus/safety-rules/src/t_safety_rules.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/t_safety_rules.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/t_safety_rules.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/t_safety_rules.rs diff --git a/core/src/pos/consensus/safety-rules/src/test_utils.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/test_utils.rs similarity index 98% rename from core/src/pos/consensus/safety-rules/src/test_utils.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/test_utils.rs index 4037dc6ebb..ff7a5806fb 100644 --- a/core/src/pos/consensus/safety-rules/src/test_utils.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/test_utils.rs @@ -64,8 +64,7 @@ pub fn make_genesis( pub fn make_proposal_with_qc_and_proof( payload: Payload, round: Round, proof: Proof, qc: QuorumCert, validator_signer: &ValidatorSigner, exec_key: Option<&BLSPrivateKey>, -) -> MaybeSignedVoteProposal -{ +) -> MaybeSignedVoteProposal { let vote_proposal = VoteProposal::new( proof, Block::new_proposal( @@ -88,8 +87,7 @@ pub fn make_proposal_with_qc_and_proof( pub fn make_proposal_with_qc( round: Round, qc: QuorumCert, validator_signer: &ValidatorSigner, exec_key: Option<&BLSPrivateKey>, -) -> MaybeSignedVoteProposal -{ +) -> MaybeSignedVoteProposal { make_proposal_with_qc_and_proof( vec![], round, @@ -105,8 +103,7 @@ pub fn make_proposal_with_parent_and_overrides( committed: Option<&MaybeSignedVoteProposal>, validator_signer: &ValidatorSigner, epoch: Option, next_epoch_state: Option, exec_key: Option<&BLSPrivateKey>, -) -> MaybeSignedVoteProposal -{ +) -> MaybeSignedVoteProposal { let block_epoch = match epoch { Some(e) => e, _ => parent.block().epoch(), @@ -203,8 +200,7 @@ pub fn make_proposal_with_parent( payload: Payload, round: Round, parent: &MaybeSignedVoteProposal, committed: Option<&MaybeSignedVoteProposal>, validator_signer: &ValidatorSigner, exec_key: Option<&BLSPrivateKey>, -) -> MaybeSignedVoteProposal -{ +) -> MaybeSignedVoteProposal { make_proposal_with_parent_and_overrides( payload, round, diff --git a/core/src/pos/consensus/safety-rules/src/tests/local.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/local.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/tests/local.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/local.rs diff --git a/core/src/pos/consensus/safety-rules/src/tests/mod.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/mod.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/tests/mod.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/mod.rs diff --git a/core/src/pos/consensus/safety-rules/src/tests/networking.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/networking.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/tests/networking.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/networking.rs diff --git a/core/src/pos/consensus/safety-rules/src/tests/safety_rules.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/safety_rules.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/tests/safety_rules.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/safety_rules.rs diff --git a/core/src/pos/consensus/safety-rules/src/tests/serializer.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/serializer.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/tests/serializer.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/serializer.rs diff --git a/core/src/pos/consensus/safety-rules/src/tests/suite.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/suite.rs similarity index 99% rename from core/src/pos/consensus/safety-rules/src/tests/suite.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/suite.rs index 676fa3acf9..ec9845af82 100644 --- a/core/src/pos/consensus/safety-rules/src/tests/suite.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/suite.rs @@ -27,8 +27,7 @@ type Proof = test_utils::Proof; fn make_proposal_with_qc_and_proof( round: Round, proof: Proof, qc: QuorumCert, signer: &ValidatorSigner, exec_key: Option<&BLSPrivateKey>, -) -> MaybeSignedVoteProposal -{ +) -> MaybeSignedVoteProposal { test_utils::make_proposal_with_qc_and_proof( vec![], round, @@ -43,8 +42,7 @@ fn make_proposal_with_parent( round: Round, parent: &MaybeSignedVoteProposal, committed: Option<&MaybeSignedVoteProposal>, signer: &ValidatorSigner, exec_key: Option<&BLSPrivateKey>, -) -> MaybeSignedVoteProposal -{ +) -> MaybeSignedVoteProposal { test_utils::make_proposal_with_parent( vec![], round, @@ -56,9 +54,7 @@ fn make_proposal_with_parent( } pub type Callback = Box< - dyn Fn( - /* prevent cargo format failing */ - ) -> ( + dyn Fn(/* prevent cargo format failing */) -> ( Box, ValidatorSigner, Option, diff --git a/core/src/pos/consensus/safety-rules/src/tests/thread.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/thread.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/tests/thread.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/thread.rs diff --git a/core/src/pos/consensus/safety-rules/src/tests/vault.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/vault.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/src/tests/vault.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/tests/vault.rs diff --git a/core/src/pos/consensus/safety-rules/src/thread.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/thread.rs similarity index 99% rename from core/src/pos/consensus/safety-rules/src/thread.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/src/thread.rs index cc546cc05d..e2d1084fac 100644 --- a/core/src/pos/consensus/safety-rules/src/thread.rs +++ b/crates/cfxcore/core/src/pos/consensus/safety-rules/src/thread.rs @@ -36,8 +36,7 @@ impl ThreadService { pub fn new( storage: PersistentSafetyStorage, verify_vote_proposal_signature: bool, export_consensus_key: bool, timeout: u64, - ) -> Self - { + ) -> Self { let listen_port = utils::get_available_port(); let listen_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), listen_port); diff --git a/core/src/pos/consensus/safety-rules/tests/binary.rs b/crates/cfxcore/core/src/pos/consensus/safety-rules/tests/binary.rs similarity index 100% rename from core/src/pos/consensus/safety-rules/tests/binary.rs rename to crates/cfxcore/core/src/pos/consensus/safety-rules/tests/binary.rs diff --git a/core/src/pos/consensus/state_computer.rs b/crates/cfxcore/core/src/pos/consensus/state_computer.rs similarity index 97% rename from core/src/pos/consensus/state_computer.rs rename to crates/cfxcore/core/src/pos/consensus/state_computer.rs index ad4a7c929b..279e17c262 100644 --- a/core/src/pos/consensus/state_computer.rs +++ b/crates/cfxcore/core/src/pos/consensus/state_computer.rs @@ -56,8 +56,7 @@ impl StateComputer for ExecutionProxy { // The parent block id. parent_block_id: HashValue, catch_up_mode: bool, - ) -> Result - { + ) -> Result { fail_point!("consensus::compute", |_| { Err(ExecutionError::InternalError { error: "Injected error in compute".into(), @@ -85,8 +84,7 @@ impl StateComputer for ExecutionProxy { async fn commit( &self, block_ids: Vec, finality_proof: LedgerInfoWithSignatures, - ) -> Result<(), ExecutionError> - { + ) -> Result<(), ExecutionError> { let (committed_txns, reconfig_events) = monitor!( "commit_block", self.executor diff --git a/core/src/pos/consensus/state_replication.rs b/crates/cfxcore/core/src/pos/consensus/state_replication.rs similarity index 100% rename from core/src/pos/consensus/state_replication.rs rename to crates/cfxcore/core/src/pos/consensus/state_replication.rs diff --git a/core/src/pos/consensus/test_utils/mock_state_computer.rs b/crates/cfxcore/core/src/pos/consensus/test_utils/mock_state_computer.rs similarity index 98% rename from core/src/pos/consensus/test_utils/mock_state_computer.rs rename to crates/cfxcore/core/src/pos/consensus/test_utils/mock_state_computer.rs index 56a9dbdd9c..fef0eda611 100644 --- a/core/src/pos/consensus/test_utils/mock_state_computer.rs +++ b/crates/cfxcore/core/src/pos/consensus/test_utils/mock_state_computer.rs @@ -32,8 +32,7 @@ impl MockStateComputer { state_sync_client: mpsc::UnboundedSender, commit_callback: mpsc::UnboundedSender, consensus_db: Arc, - ) -> Self - { + ) -> Self { MockStateComputer { state_sync_client, commit_callback, @@ -111,8 +110,7 @@ impl StateComputer for EmptyStateComputer { fn compute( &self, _block: &Block, _parent_block_id: HashValue, _catch_up_mode: bool, - ) -> Result - { + ) -> Result { Ok(StateComputeResult::new( *ACCUMULATOR_PLACEHOLDER_HASH, vec![], diff --git a/core/src/pos/consensus/test_utils/mock_storage.rs b/crates/cfxcore/core/src/pos/consensus/test_utils/mock_storage.rs similarity index 100% rename from core/src/pos/consensus/test_utils/mock_storage.rs rename to crates/cfxcore/core/src/pos/consensus/test_utils/mock_storage.rs diff --git a/core/src/pos/consensus/test_utils/mock_txn_manager.rs b/crates/cfxcore/core/src/pos/consensus/test_utils/mock_txn_manager.rs similarity index 98% rename from core/src/pos/consensus/test_utils/mock_txn_manager.rs rename to crates/cfxcore/core/src/pos/consensus/test_utils/mock_txn_manager.rs index a7e1e79970..e4b494c537 100644 --- a/core/src/pos/consensus/test_utils/mock_txn_manager.rs +++ b/crates/cfxcore/core/src/pos/consensus/test_utils/mock_txn_manager.rs @@ -70,8 +70,7 @@ impl TxnManager for MockTransactionManager { async fn pull_txns( &self, _max_size: u64, _exclude_txns: Vec<&Payload>, _hash: HashValue, _validators: ValidatorVerifier, - ) -> Result - { + ) -> Result { // generate 1k txn is too slow with coverage instrumentation Ok(random_payload(10)) } diff --git a/core/src/pos/consensus/test_utils/mod.rs b/crates/cfxcore/core/src/pos/consensus/test_utils/mod.rs similarity index 99% rename from core/src/pos/consensus/test_utils/mod.rs rename to crates/cfxcore/core/src/pos/consensus/test_utils/mod.rs index ef1e12e712..d735c3d9f9 100644 --- a/core/src/pos/consensus/test_utils/mod.rs +++ b/crates/cfxcore/core/src/pos/consensus/test_utils/mod.rs @@ -122,8 +122,7 @@ impl TreeInserter { pub fn insert_block( &mut self, parent: &ExecutedBlock, round: Round, committed_block: Option, - ) -> Arc - { + ) -> Arc { // Node must carry a QC to its parent let parent_qc = self.create_qc_for_block(parent, committed_block); self.insert_block_with_qc(parent_qc, parent, round) @@ -166,8 +165,7 @@ impl TreeInserter { pub fn create_block_with_qc( &self, parent_qc: QuorumCert, timestamp_usecs: u64, round: Round, payload: Payload, - ) -> Block - { + ) -> Block { Block::new_proposal( payload, round, diff --git a/core/src/pos/consensus/twins/basic_twins_test.rs b/crates/cfxcore/core/src/pos/consensus/twins/basic_twins_test.rs similarity index 100% rename from core/src/pos/consensus/twins/basic_twins_test.rs rename to crates/cfxcore/core/src/pos/consensus/twins/basic_twins_test.rs diff --git a/core/src/pos/consensus/twins/mod.rs b/crates/cfxcore/core/src/pos/consensus/twins/mod.rs similarity index 100% rename from core/src/pos/consensus/twins/mod.rs rename to crates/cfxcore/core/src/pos/consensus/twins/mod.rs diff --git a/core/src/pos/consensus/twins/twins_node.rs b/crates/cfxcore/core/src/pos/consensus/twins/twins_node.rs similarity index 100% rename from core/src/pos/consensus/twins/twins_node.rs rename to crates/cfxcore/core/src/pos/consensus/twins/twins_node.rs diff --git a/core/src/pos/consensus/txn_manager.rs b/crates/cfxcore/core/src/pos/consensus/txn_manager.rs similarity index 98% rename from core/src/pos/consensus/txn_manager.rs rename to crates/cfxcore/core/src/pos/consensus/txn_manager.rs index 9eeb1e3681..45036e4c5c 100644 --- a/core/src/pos/consensus/txn_manager.rs +++ b/crates/cfxcore/core/src/pos/consensus/txn_manager.rs @@ -42,8 +42,7 @@ impl MempoolProxy { consensus_to_mempool_sender: mpsc::Sender, poll_count: u64, mempool_txn_pull_timeout_ms: u64, mempool_executed_txn_timeout_ms: u64, - ) -> Self - { + ) -> Self { assert!( poll_count > 0, "poll_count = 0 won't pull any txns from mempool" @@ -59,8 +58,7 @@ impl MempoolProxy { async fn pull_internal( &self, max_size: u64, exclude_txns: Vec, parent_block_id: HashValue, validators: ValidatorVerifier, - ) -> Result - { + ) -> Result { let (callback, callback_rcv) = oneshot::channel(); let req = ConsensusRequest::GetBlockRequest( max_size, @@ -105,8 +103,7 @@ impl TxnManager for MempoolProxy { async fn pull_txns( &self, max_size: u64, exclude_payloads: Vec<&Payload>, parent_block_id: HashValue, validators: ValidatorVerifier, - ) -> Result - { + ) -> Result { fail_point!("consensus::pull_txns", |_| { Err(anyhow::anyhow!("Injected error in pull_txns").into()) }); diff --git a/core/src/pos/consensus/util/config_subscription.rs b/crates/cfxcore/core/src/pos/consensus/util/config_subscription.rs similarity index 100% rename from core/src/pos/consensus/util/config_subscription.rs rename to crates/cfxcore/core/src/pos/consensus/util/config_subscription.rs diff --git a/core/src/pos/consensus/util/mock_time_service.rs b/crates/cfxcore/core/src/pos/consensus/util/mock_time_service.rs similarity index 100% rename from core/src/pos/consensus/util/mock_time_service.rs rename to crates/cfxcore/core/src/pos/consensus/util/mock_time_service.rs diff --git a/core/src/pos/consensus/util/mod.rs b/crates/cfxcore/core/src/pos/consensus/util/mod.rs similarity index 100% rename from core/src/pos/consensus/util/mod.rs rename to crates/cfxcore/core/src/pos/consensus/util/mod.rs diff --git a/core/src/pos/consensus/util/time_service.rs b/crates/cfxcore/core/src/pos/consensus/util/time_service.rs similarity index 100% rename from core/src/pos/consensus/util/time_service.rs rename to crates/cfxcore/core/src/pos/consensus/util/time_service.rs diff --git a/core/src/pos/crypto/crypto-derive/Cargo.toml b/crates/cfxcore/core/src/pos/crypto/crypto-derive/Cargo.toml similarity index 100% rename from core/src/pos/crypto/crypto-derive/Cargo.toml rename to crates/cfxcore/core/src/pos/crypto/crypto-derive/Cargo.toml diff --git a/core/src/pos/crypto/crypto-derive/src/hasher.rs b/crates/cfxcore/core/src/pos/crypto/crypto-derive/src/hasher.rs similarity index 100% rename from core/src/pos/crypto/crypto-derive/src/hasher.rs rename to crates/cfxcore/core/src/pos/crypto/crypto-derive/src/hasher.rs diff --git a/core/src/pos/crypto/crypto-derive/src/lib.rs b/crates/cfxcore/core/src/pos/crypto/crypto-derive/src/lib.rs similarity index 100% rename from core/src/pos/crypto/crypto-derive/src/lib.rs rename to crates/cfxcore/core/src/pos/crypto/crypto-derive/src/lib.rs diff --git a/core/src/pos/crypto/crypto-derive/src/unions.rs b/crates/cfxcore/core/src/pos/crypto/crypto-derive/src/unions.rs similarity index 99% rename from core/src/pos/crypto/crypto-derive/src/unions.rs rename to crates/cfxcore/core/src/pos/crypto/crypto-derive/src/unions.rs index 08bacd427b..2d67dadf1a 100644 --- a/core/src/pos/crypto/crypto-derive/src/unions.rs +++ b/crates/cfxcore/core/src/pos/crypto/crypto-derive/src/unions.rs @@ -193,8 +193,7 @@ pub fn impl_enum_privatekey( pub fn impl_enum_verifyingkey( name: &Ident, private_key_type: syn::LitStr, signature_type: syn::LitStr, _variants: &DataEnum, -) -> TokenStream -{ +) -> TokenStream { let pkt: syn::Type = private_key_type.parse().unwrap(); let st: syn::Type = signature_type.parse().unwrap(); let res = quote! { @@ -210,8 +209,7 @@ pub fn impl_enum_verifyingkey( pub fn impl_enum_signingkey( name: &Ident, public_key_type: syn::LitStr, signature_type: syn::LitStr, variants: &DataEnum, -) -> TokenStream -{ +) -> TokenStream { let pkt: syn::Type = public_key_type.parse().unwrap(); let st: syn::Type = signature_type.parse().unwrap(); @@ -253,8 +251,7 @@ pub fn impl_enum_signingkey( pub fn impl_enum_signature( name: &Ident, public_key_type: syn::LitStr, private_key_type: syn::LitStr, variants: &DataEnum, -) -> TokenStream -{ +) -> TokenStream { let priv_kt: syn::Type = private_key_type.parse().unwrap(); let pub_kt: syn::Type = public_key_type.parse().unwrap(); let mut res = impl_enum_tryfrom(name, variants); diff --git a/core/src/pos/crypto/crypto/Cargo.toml b/crates/cfxcore/core/src/pos/crypto/crypto/Cargo.toml similarity index 94% rename from core/src/pos/crypto/crypto/Cargo.toml rename to crates/cfxcore/core/src/pos/crypto/crypto/Cargo.toml index ec8d970513..d2d60ec5bf 100644 --- a/core/src/pos/crypto/crypto/Cargo.toml +++ b/crates/cfxcore/core/src/pos/crypto/crypto/Cargo.toml @@ -34,14 +34,14 @@ x25519-dalek = { version = "0.1.0", package = "x25519-dalek-fiat", default-featu aes-gcm = "0.8.0" diem-crypto-derive = { path = "../crypto-derive", version = "0.1.0" } bcs = "0.1.2" -cfxkey = { path = "../../../../../accounts/cfxkey" } -cfx-types = { path = "../../../../../cfx_types" } +cfxkey = { path = "../../../../../../cfx_key" } +cfx-types = { path = "../../../../../../cfx_types" } bls-signatures = {git = "https://github.com/Conflux-Chain/bls-signatures.git", rev = "fb52187df92d27c365642cb7e7b2aaf60437cf9c", default-features = false, features = ["multicore"]} vrf = "0.2.2" lazy_static = "1.4" parking_lot = "0.11" openssl = "0.10" -diem-logger = {path = "../../common/logger"} +diem-logger = {path = "../../common/logger" } pkcs8 = {version = "0.7.5", features = ["encryption", "std"]} diff --git a/core/src/pos/crypto/crypto/README.md b/crates/cfxcore/core/src/pos/crypto/crypto/README.md similarity index 100% rename from core/src/pos/crypto/crypto/README.md rename to crates/cfxcore/core/src/pos/crypto/crypto/README.md diff --git a/core/src/pos/crypto/crypto/benches/bls.rs b/crates/cfxcore/core/src/pos/crypto/crypto/benches/bls.rs similarity index 100% rename from core/src/pos/crypto/crypto/benches/bls.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/benches/bls.rs diff --git a/core/src/pos/crypto/crypto/benches/ed25519.rs b/crates/cfxcore/core/src/pos/crypto/crypto/benches/ed25519.rs similarity index 100% rename from core/src/pos/crypto/crypto/benches/ed25519.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/benches/ed25519.rs diff --git a/core/src/pos/crypto/crypto/benches/noise.rs b/crates/cfxcore/core/src/pos/crypto/crypto/benches/noise.rs similarity index 100% rename from core/src/pos/crypto/crypto/benches/noise.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/benches/noise.rs diff --git a/core/src/pos/crypto/crypto/benches/vrf.rs b/crates/cfxcore/core/src/pos/crypto/crypto/benches/vrf.rs similarity index 100% rename from core/src/pos/crypto/crypto/benches/vrf.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/benches/vrf.rs diff --git a/core/src/pos/crypto/crypto/src/bls.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/bls.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/bls.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/bls.rs diff --git a/core/src/pos/crypto/crypto/src/compat.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/compat.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/compat.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/compat.rs diff --git a/core/src/pos/crypto/crypto/src/ec_vrf.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/ec_vrf.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/ec_vrf.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/ec_vrf.rs diff --git a/core/src/pos/crypto/crypto/src/ed25519.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/ed25519.rs similarity index 99% rename from core/src/pos/crypto/crypto/src/ed25519.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/ed25519.rs index 2d473755bc..a8c4fd8d73 100644 --- a/core/src/pos/crypto/crypto/src/ed25519.rs +++ b/crates/cfxcore/core/src/pos/crypto/crypto/src/ed25519.rs @@ -460,8 +460,7 @@ impl Signature for Ed25519Signature { fn batch_verify( message: &T, keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self)>, - ) -> Result<()> - { + ) -> Result<()> { for (_, sig) in keys_and_signatures.iter() { Ed25519Signature::check_malleability(&sig.to_bytes())? } diff --git a/core/src/pos/crypto/crypto/src/error.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/error.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/error.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/error.rs diff --git a/core/src/pos/crypto/crypto/src/hash.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/hash.rs similarity index 99% rename from core/src/pos/crypto/crypto/src/hash.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/hash.rs index 350048532f..c815b5d64c 100644 --- a/core/src/pos/crypto/crypto/src/hash.rs +++ b/crates/cfxcore/core/src/pos/crypto/crypto/src/hash.rs @@ -21,11 +21,11 @@ //! Alice signed the message she needed to be aware of how other applications //! might interpret that message. //! -//! 2. **Format Ambiguity**: imagine a program that hashes a pair of strings. -//! To hash the strings `a` and `b` it hashes `a + "||" + b`. The pair of +//! 2. **Format Ambiguity**: imagine a program that hashes a pair of strings. To +//! hash the strings `a` and `b` it hashes `a + "||" + b`. The pair of //! strings `a="foo||", b = "bar"` and `a="foo", b = "||bar"` result in the -//! same input to the hash function and therefore the same hash. This -//! creates a collision. +//! same input to the hash function and therefore the same hash. This creates +//! a collision. //! //! Regarding (1), this library makes it easy for Diem developers to create as //! many new "hashable" Rust types as needed so that each Rust type hashed and diff --git a/core/src/pos/crypto/crypto/src/hkdf.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/hkdf.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/hkdf.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/hkdf.rs diff --git a/core/src/pos/crypto/crypto/src/key_file.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/key_file.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/key_file.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/key_file.rs diff --git a/core/src/pos/crypto/crypto/src/lib.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/lib.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/lib.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/lib.rs diff --git a/core/src/pos/crypto/crypto/src/multi_bls.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/multi_bls.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/multi_bls.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/multi_bls.rs diff --git a/core/src/pos/crypto/crypto/src/multi_ed25519.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/multi_ed25519.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/multi_ed25519.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/multi_ed25519.rs diff --git a/core/src/pos/crypto/crypto/src/noise.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/noise.rs similarity index 99% rename from core/src/pos/crypto/crypto/src/noise.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/noise.rs index 635133853f..beb7c54dca 100644 --- a/core/src/pos/crypto/crypto/src/noise.rs +++ b/crates/cfxcore/core/src/pos/crypto/crypto/src/noise.rs @@ -60,7 +60,6 @@ //! # Ok(()) //! # } //! ``` -//! #![allow(clippy::integer_arithmetic)] use crate::{hash::HashValue, hkdf::Hkdf, traits::Uniform as _, x25519}; @@ -283,8 +282,7 @@ impl NoiseConfig { &self, rng: &mut (impl rand::RngCore + rand::CryptoRng), prologue: &[u8], remote_public: x25519::PublicKey, payload: Option<&[u8]>, response_buffer: &mut [u8], - ) -> Result - { + ) -> Result { // checks let payload_len = payload.map(<[u8]>::len).unwrap_or(0); let buffer_size_required = handshake_init_msg_len(payload_len); @@ -364,8 +362,7 @@ impl NoiseConfig { pub fn finalize_connection( &self, handshake_state: InitiatorHandshakeState, received_message: &[u8], - ) -> Result<(Vec, NoiseSession), NoiseError> - { + ) -> Result<(Vec, NoiseSession), NoiseError> { // checks if received_message.len() > MAX_SIZE_NOISE_MSG { return Err(NoiseError::ReceivedMsgTooLarge); @@ -520,8 +517,7 @@ impl NoiseConfig { &self, rng: &mut (impl rand::RngCore + rand::CryptoRng), handshake_state: ResponderHandshakeState, payload: Option<&[u8]>, response_buffer: &mut [u8], - ) -> Result - { + ) -> Result { // checks let payload_len = payload.map(<[u8]>::len).unwrap_or(0); let buffer_size_required = handshake_resp_msg_len(payload_len); @@ -594,8 +590,7 @@ impl NoiseConfig { NoiseSession, // The created session ), NoiseError, - > - { + > { let (_, handshake_state, received_payload) = self.parse_client_init_message(prologue, received_message)?; let session = self.respond_to_client( @@ -634,8 +629,7 @@ impl NoiseSession { fn new( write_key: Vec, read_key: Vec, remote_public_key: x25519::PublicKey, - ) -> Self - { + ) -> Self { Self { valid: true, remote_public_key, diff --git a/core/src/pos/crypto/crypto/src/secp256k1.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/secp256k1.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/secp256k1.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/secp256k1.rs diff --git a/core/src/pos/crypto/crypto/src/tags.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/tags.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/tags.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/tags.rs diff --git a/core/src/pos/crypto/crypto/src/test_utils.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/test_utils.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/test_utils.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/test_utils.rs diff --git a/core/src/pos/crypto/crypto/src/traits.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/traits.rs similarity index 99% rename from core/src/pos/crypto/crypto/src/traits.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/traits.rs index be0b2848c5..b98a12a0b7 100644 --- a/core/src/pos/crypto/crypto/src/traits.rs +++ b/crates/cfxcore/core/src/pos/crypto/crypto/src/traits.rs @@ -253,8 +253,7 @@ pub trait Signature: fn batch_verify( message: &T, keys_and_signatures: Vec<(Self::VerifyingKeyMaterial, Self)>, - ) -> Result<()> - { + ) -> Result<()> { for (key, signature) in keys_and_signatures { signature.verify(message, &key)? } diff --git a/core/src/pos/crypto/crypto/src/unit_tests/bcs_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/bcs_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/bcs_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/bcs_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/compat_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compat_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/compat_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compat_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_pub.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_pub.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_pub.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_pub.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_sig.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_sig.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_sig.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/cross_test_trait_obj_sig.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/compilation/small_kdf.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/small_kdf.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/compilation/small_kdf.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/compilation/small_kdf.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/cross_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/cross_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/cross_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/cross_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/cryptohasher.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/cryptohasher.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/cryptohasher.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/cryptohasher.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/ed25519_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/ed25519_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/ed25519_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/ed25519_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/hash_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/hash_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/hash_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/hash_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/hkdf_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/hkdf_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/hkdf_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/hkdf_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/mod.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/mod.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/mod.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/mod.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/multi_ed25519_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/multi_ed25519_test.rs similarity index 99% rename from core/src/pos/crypto/crypto/src/unit_tests/multi_ed25519_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/multi_ed25519_test.rs index 929bf4890f..d2ee8e0d51 100644 --- a/core/src/pos/crypto/crypto/src/unit_tests/multi_ed25519_test.rs +++ b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/multi_ed25519_test.rs @@ -50,8 +50,7 @@ fn test_successful_public_key_serialization( fn test_failed_public_key_serialization( result: std::result::Result, expected_error: CryptoMaterialError, -) -{ +) { assert!(result.is_err()); assert_eq!(result.err().unwrap(), expected_error); } diff --git a/core/src/pos/crypto/crypto/src/unit_tests/noise_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/noise_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/noise_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/noise_test.rs diff --git a/core/src/pos/crypto/crypto/src/unit_tests/secp256k1_test.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/secp256k1_test.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/unit_tests/secp256k1_test.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/unit_tests/secp256k1_test.rs diff --git a/core/src/pos/crypto/crypto/src/vdf_sha3.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/vdf_sha3.rs similarity index 100% rename from core/src/pos/crypto/crypto/src/vdf_sha3.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/vdf_sha3.rs diff --git a/core/src/pos/crypto/crypto/src/x25519.rs b/crates/cfxcore/core/src/pos/crypto/crypto/src/x25519.rs similarity index 99% rename from core/src/pos/crypto/crypto/src/x25519.rs rename to crates/cfxcore/core/src/pos/crypto/crypto/src/x25519.rs index 5b358d366c..0a0114649b 100644 --- a/core/src/pos/crypto/crypto/src/x25519.rs +++ b/crates/cfxcore/core/src/pos/crypto/crypto/src/x25519.rs @@ -35,7 +35,6 @@ //! # Ok(()) //! # } //! ``` -//! use crate::{ traits::{ diff --git a/core/src/pos/crypto/crypto/test_vectors/noise_cacophony.txt b/crates/cfxcore/core/src/pos/crypto/crypto/test_vectors/noise_cacophony.txt similarity index 100% rename from core/src/pos/crypto/crypto/test_vectors/noise_cacophony.txt rename to crates/cfxcore/core/src/pos/crypto/crypto/test_vectors/noise_cacophony.txt diff --git a/core/src/pos/mempool/core_mempool/index.rs b/crates/cfxcore/core/src/pos/mempool/core_mempool/index.rs similarity index 99% rename from core/src/pos/mempool/core_mempool/index.rs rename to crates/cfxcore/core/src/pos/mempool/core_mempool/index.rs index 274f7389a5..f9c1191fe5 100644 --- a/core/src/pos/mempool/core_mempool/index.rs +++ b/crates/cfxcore/core/src/pos/mempool/core_mempool/index.rs @@ -56,8 +56,7 @@ impl AccountTransactions { pub(crate) fn insert( &mut self, hash: HashValue, txn: MempoolTransaction, is_pivot_decision: bool, - ) - { + ) { if is_pivot_decision { self.pivot_decision_transaction.insert(hash, txn); } else { diff --git a/core/src/pos/mempool/core_mempool/mempool.rs b/crates/cfxcore/core/src/pos/mempool/core_mempool/mempool.rs similarity index 98% rename from core/src/pos/mempool/core_mempool/mempool.rs rename to crates/cfxcore/core/src/pos/mempool/core_mempool/mempool.rs index a99d04e1b2..b1463e0183 100644 --- a/core/src/pos/mempool/core_mempool/mempool.rs +++ b/crates/cfxcore/core/src/pos/mempool/core_mempool/mempool.rs @@ -30,7 +30,7 @@ use diem_types::{ }, validator_verifier::ValidatorVerifier, }; -use executor::vm::FakeVM; +use executor::vm::verify_dispute; use std::{ collections::HashSet, time::{Duration, SystemTime}, @@ -105,8 +105,7 @@ impl Mempool { pub(crate) fn add_txn( &mut self, txn: SignedTransaction, ranking_score: u64, timeline_state: TimelineState, governance_role: GovernanceRole, - ) -> MempoolStatus - { + ) -> MempoolStatus { diem_trace!(LogSchema::new(LogEntry::AddTxn) .txns(TxnsLog::new_txn(txn.sender(), txn.hash())),); @@ -136,8 +135,7 @@ impl Mempool { pub(crate) fn get_block( &mut self, _batch_size: u64, mut seen: HashSet, pos_state: &PosState, validators: ValidatorVerifier, - ) -> Vec - { + ) -> Vec { let mut block = vec![]; let mut block_log = TxnsLog::new(); // Helper DS. Helps to mitigate scenarios where account submits several @@ -166,8 +164,8 @@ impl Mempool { TransactionPayload::Dispute(dispute_payload) => { // TODO(lpl): Only dispute a node once. pos_state.validate_dispute(dispute_payload).and( - FakeVM::verify_dispute(dispute_payload) - .then(|| ()) + verify_dispute(dispute_payload) + .then_some(()) .ok_or(anyhow::anyhow!("invalid dispute")), ) } diff --git a/core/src/pos/mempool/core_mempool/mod.rs b/crates/cfxcore/core/src/pos/mempool/core_mempool/mod.rs similarity index 100% rename from core/src/pos/mempool/core_mempool/mod.rs rename to crates/cfxcore/core/src/pos/mempool/core_mempool/mod.rs diff --git a/core/src/pos/mempool/core_mempool/transaction.rs b/crates/cfxcore/core/src/pos/mempool/core_mempool/transaction.rs similarity index 98% rename from core/src/pos/mempool/core_mempool/transaction.rs rename to crates/cfxcore/core/src/pos/mempool/core_mempool/transaction.rs index a37e441ad2..00ac21d4da 100644 --- a/core/src/pos/mempool/core_mempool/transaction.rs +++ b/crates/cfxcore/core/src/pos/mempool/core_mempool/transaction.rs @@ -28,8 +28,7 @@ impl MempoolTransaction { pub(crate) fn new( txn: SignedTransaction, expiration_time: Duration, ranking_score: u64, timeline_state: TimelineState, governance_role: GovernanceRole, - ) -> Self - { + ) -> Self { Self { txn, ranking_score, diff --git a/core/src/pos/mempool/core_mempool/transaction_store.rs b/crates/cfxcore/core/src/pos/mempool/core_mempool/transaction_store.rs similarity index 99% rename from core/src/pos/mempool/core_mempool/transaction_store.rs rename to crates/cfxcore/core/src/pos/mempool/core_mempool/transaction_store.rs index c0f977eca4..2ef8df770a 100644 --- a/core/src/pos/mempool/core_mempool/transaction_store.rs +++ b/crates/cfxcore/core/src/pos/mempool/core_mempool/transaction_store.rs @@ -259,8 +259,7 @@ impl TransactionStore { pub(crate) fn gc_by_system_ttl( &mut self, metrics_cache: &TtlCache<(AccountAddress, HashValue), SystemTime>, - ) - { + ) { let now = diem_infallible::duration_since_epoch(); self.gc(now, true, metrics_cache); @@ -271,16 +270,14 @@ impl TransactionStore { pub(crate) fn gc_by_expiration_time( &mut self, block_time: Duration, metrics_cache: &TtlCache<(AccountAddress, HashValue), SystemTime>, - ) - { + ) { self.gc(block_time, false, metrics_cache); } fn gc( &mut self, now: Duration, by_system_ttl: bool, _metrics_cache: &TtlCache<(AccountAddress, HashValue), SystemTime>, - ) - { + ) { let (metric_label, index, log_event) = if by_system_ttl { ( counters::GC_SYSTEM_TTL_LABEL, diff --git a/core/src/pos/mempool/core_mempool/ttl_cache.rs b/crates/cfxcore/core/src/pos/mempool/core_mempool/ttl_cache.rs similarity index 100% rename from core/src/pos/mempool/core_mempool/ttl_cache.rs rename to crates/cfxcore/core/src/pos/mempool/core_mempool/ttl_cache.rs diff --git a/core/src/pos/mempool/counters.rs b/crates/cfxcore/core/src/pos/mempool/counters.rs similarity index 100% rename from core/src/pos/mempool/counters.rs rename to crates/cfxcore/core/src/pos/mempool/counters.rs diff --git a/core/src/pos/mempool/logging.rs b/crates/cfxcore/core/src/pos/mempool/logging.rs similarity index 99% rename from core/src/pos/mempool/logging.rs rename to crates/cfxcore/core/src/pos/mempool/logging.rs index ae7e7a3643..2fe35151a0 100644 --- a/core/src/pos/mempool/logging.rs +++ b/crates/cfxcore/core/src/pos/mempool/logging.rs @@ -51,8 +51,7 @@ impl TxnsLog { pub fn add_full_metadata( &mut self, account: AccountAddress, hash: HashValue, status: &str, timestamp: Option, - ) - { + ) { self.txns .push((account, hash, Some(status.to_string()), timestamp)); } diff --git a/core/src/pos/mempool/mod.rs b/crates/cfxcore/core/src/pos/mempool/mod.rs similarity index 100% rename from core/src/pos/mempool/mod.rs rename to crates/cfxcore/core/src/pos/mempool/mod.rs diff --git a/core/src/pos/mempool/shared_mempool/coordinator.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/coordinator.rs similarity index 99% rename from core/src/pos/mempool/shared_mempool/coordinator.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/coordinator.rs index 143d27fbb8..c2da0b2483 100644 --- a/core/src/pos/mempool/shared_mempool/coordinator.rs +++ b/crates/cfxcore/core/src/pos/mempool/shared_mempool/coordinator.rs @@ -55,8 +55,7 @@ pub(crate) async fn coordinator( (), OnChainConfigPayload, >, -) -{ +) { diem_info!(LogSchema::event_log( LogEntry::CoordinatorRuntime, LogEvent::Start @@ -123,8 +122,7 @@ async fn handle_client_event( callback: oneshot::Sender< anyhow::Result<(MempoolStatus, Option)>, >, -) -{ +) { diem_debug!("handle_client_event"); // This timer measures how long it took for the bounded executor to // *schedule* the task. @@ -160,8 +158,7 @@ fn handle_state_sync_request(smp: &mut SharedMempool, msg: CommitNotification) { async fn handle_mempool_reconfig_event( smp: &mut SharedMempool, bounded_executor: &BoundedExecutor, config_update: OnChainConfigPayload, -) -{ +) { diem_info!(LogSchema::event_log( LogEntry::ReconfigUpdate, LogEvent::Received @@ -182,8 +179,7 @@ async fn handle_mempool_reconfig_event( async fn handle_mempool_sync_msg( bounded_executor: &BoundedExecutor, smp: &mut SharedMempool, peer: NodeId, msg: MempoolSyncMsg, -) -{ +) { counters::shared_mempool_event_inc("message"); match msg { MempoolSyncMsg::BroadcastTransactionsRequest { diff --git a/core/src/pos/mempool/shared_mempool/mod.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/mod.rs similarity index 100% rename from core/src/pos/mempool/shared_mempool/mod.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/mod.rs diff --git a/core/src/pos/mempool/shared_mempool/network.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/network.rs similarity index 100% rename from core/src/pos/mempool/shared_mempool/network.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/network.rs diff --git a/core/src/pos/mempool/shared_mempool/peer_manager.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/peer_manager.rs similarity index 99% rename from core/src/pos/mempool/shared_mempool/peer_manager.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/peer_manager.rs index 0edd215f52..f19d939a25 100644 --- a/core/src/pos/mempool/shared_mempool/peer_manager.rs +++ b/crates/cfxcore/core/src/pos/mempool/shared_mempool/peer_manager.rs @@ -124,8 +124,7 @@ impl PeerManager { pub fn add_peer( &self, peer: NodeId, //metadata: ConnectionMetadata, - ) -> bool - { + ) -> bool { diem_debug!("PeerManager::add_peer [{:?}]", peer); let mut peer_states = self.peer_states.lock(); let is_new_peer = !peer_states.contains_key(&peer); @@ -377,8 +376,7 @@ impl PeerManager { pub fn process_broadcast_ack( &self, peer: NodeId, request_id_bytes: Vec, retry: bool, backoff: bool, timestamp: SystemTime, - ) - { + ) { let batch_id = if let Ok(id) = bcs::from_bytes::(&request_id_bytes) { diff --git a/core/src/pos/mempool/shared_mempool/runtime.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/runtime.rs similarity index 99% rename from core/src/pos/mempool/shared_mempool/runtime.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/runtime.rs index 60c34c278d..7650544b6b 100644 --- a/core/src/pos/mempool/shared_mempool/runtime.rs +++ b/crates/cfxcore/core/src/pos/mempool/shared_mempool/runtime.rs @@ -55,8 +55,7 @@ pub(crate) fn start_shared_mempool( db_with_cache: Arc, validator: Arc>, subscribers: Vec>, -) -{ +) { let peer_manager = Arc::new(PeerManager::new(config.base.role, config.mempool.clone())); @@ -97,8 +96,7 @@ pub fn bootstrap( consensus_requests: Receiver, state_sync_requests: Receiver, mempool_reconfig_events: diem_channel::Receiver<(), OnChainConfigPayload>, -) -> Runtime -{ +) -> Runtime { let runtime = Builder::new_multi_thread() .thread_name("shared-mem") .enable_all() diff --git a/core/src/pos/mempool/shared_mempool/tasks.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/tasks.rs similarity index 99% rename from core/src/pos/mempool/shared_mempool/tasks.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/tasks.rs index 902163620e..07e94fb719 100644 --- a/core/src/pos/mempool/shared_mempool/tasks.rs +++ b/crates/cfxcore/core/src/pos/mempool/shared_mempool/tasks.rs @@ -53,8 +53,7 @@ pub(crate) fn execute_broadcast( peer: NodeId, backoff: bool, smp: &mut SharedMempool, scheduled_broadcasts: &mut FuturesUnordered, broadcasting_peers: &mut HashSet, executor: Handle, -) -{ +) { diem_trace!("execute_broadcast starts: peer={}", peer); let peer_manager = &smp.peer_manager.clone(); peer_manager.execute_broadcast(peer.clone(), backoff, smp); @@ -91,8 +90,7 @@ pub(crate) fn execute_broadcast( pub(crate) async fn process_client_transaction_submission( smp: SharedMempool, transaction: SignedTransaction, callback: oneshot::Sender>, timer: HistogramTimer, -) -{ +) { timer.stop_and_record(); let _timer = counters::process_txn_submit_latency_timer( counters::CLIENT_LABEL, @@ -122,8 +120,7 @@ pub(crate) async fn process_transaction_broadcast( smp: SharedMempool, transactions: Vec, request_id: Vec, timeline_state: TimelineState, peer: NodeId, timer: HistogramTimer, -) -{ +) { diem_trace!("process_transaction_broadcast starts: peer={}", peer); timer.stop_and_record(); /*let _timer = counters::process_txn_submit_latency_timer( @@ -219,8 +216,7 @@ fn is_txn_retryable(result: SubmissionStatus) -> bool { pub(crate) async fn process_incoming_transactions( smp: &SharedMempool, transactions: Vec, timeline_state: TimelineState, -) -> Vec -{ +) -> Vec { let mut statuses = vec![]; let start_storage_read = Instant::now(); @@ -373,8 +369,7 @@ pub(crate) async fn process_state_sync_request( pub(crate) async fn process_consensus_request( db: Arc, mempool: &Mutex, req: ConsensusRequest, -) -{ +) { // Start latency timer let start_time = Instant::now(); diem_debug!( @@ -458,8 +453,7 @@ pub(crate) async fn process_consensus_request( async fn commit_txns( mempool: &Mutex, transactions: Vec, block_timestamp_usecs: u64, is_rejected: bool, -) -{ +) { let mut pool = mempool.lock(); for transaction in transactions { @@ -481,8 +475,7 @@ async fn commit_txns( pub(crate) async fn process_config_update( config_update: OnChainConfigPayload, _validator: Arc>, -) -{ +) { diem_trace!(LogSchema::event_log( LogEntry::ReconfigUpdate, LogEvent::Process diff --git a/core/src/pos/mempool/shared_mempool/transaction_validator.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/transaction_validator.rs similarity index 100% rename from core/src/pos/mempool/shared_mempool/transaction_validator.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/transaction_validator.rs diff --git a/core/src/pos/mempool/shared_mempool/types.rs b/crates/cfxcore/core/src/pos/mempool/shared_mempool/types.rs similarity index 99% rename from core/src/pos/mempool/shared_mempool/types.rs rename to crates/cfxcore/core/src/pos/mempool/shared_mempool/types.rs index 57efc2649c..4235148d29 100644 --- a/core/src/pos/mempool/shared_mempool/types.rs +++ b/crates/cfxcore/core/src/pos/mempool/shared_mempool/types.rs @@ -77,8 +77,7 @@ pub enum SharedMempoolNotification { pub(crate) fn notify_subscribers( event: SharedMempoolNotification, subscribers: &[UnboundedSender], -) -{ +) { for subscriber in subscribers { let _ = subscriber.unbounded_send(event); } diff --git a/core/src/pos/mempool/tests/common.rs b/crates/cfxcore/core/src/pos/mempool/tests/common.rs similarity index 100% rename from core/src/pos/mempool/tests/common.rs rename to crates/cfxcore/core/src/pos/mempool/tests/common.rs diff --git a/core/src/pos/mempool/tests/core_mempool_test.rs b/crates/cfxcore/core/src/pos/mempool/tests/core_mempool_test.rs similarity index 100% rename from core/src/pos/mempool/tests/core_mempool_test.rs rename to crates/cfxcore/core/src/pos/mempool/tests/core_mempool_test.rs diff --git a/core/src/pos/mempool/tests/fuzzing.rs b/crates/cfxcore/core/src/pos/mempool/tests/fuzzing.rs similarity index 100% rename from core/src/pos/mempool/tests/fuzzing.rs rename to crates/cfxcore/core/src/pos/mempool/tests/fuzzing.rs diff --git a/core/src/pos/mempool/tests/mocks.rs b/crates/cfxcore/core/src/pos/mempool/tests/mocks.rs similarity index 100% rename from core/src/pos/mempool/tests/mocks.rs rename to crates/cfxcore/core/src/pos/mempool/tests/mocks.rs diff --git a/core/src/pos/mempool/tests/mod.rs b/crates/cfxcore/core/src/pos/mempool/tests/mod.rs similarity index 100% rename from core/src/pos/mempool/tests/mod.rs rename to crates/cfxcore/core/src/pos/mempool/tests/mod.rs diff --git a/core/src/pos/mempool/tests/multi_node_test.rs b/crates/cfxcore/core/src/pos/mempool/tests/multi_node_test.rs similarity index 100% rename from core/src/pos/mempool/tests/multi_node_test.rs rename to crates/cfxcore/core/src/pos/mempool/tests/multi_node_test.rs diff --git a/core/src/pos/mempool/tests/node.rs b/crates/cfxcore/core/src/pos/mempool/tests/node.rs similarity index 100% rename from core/src/pos/mempool/tests/node.rs rename to crates/cfxcore/core/src/pos/mempool/tests/node.rs diff --git a/core/src/pos/mempool/tests/shared_mempool_test.rs b/crates/cfxcore/core/src/pos/mempool/tests/shared_mempool_test.rs similarity index 100% rename from core/src/pos/mempool/tests/shared_mempool_test.rs rename to crates/cfxcore/core/src/pos/mempool/tests/shared_mempool_test.rs diff --git a/core/src/pos/mod.rs b/crates/cfxcore/core/src/pos/mod.rs similarity index 100% rename from core/src/pos/mod.rs rename to crates/cfxcore/core/src/pos/mod.rs diff --git a/core/src/pos/pos.rs b/crates/cfxcore/core/src/pos/pos.rs similarity index 98% rename from core/src/pos/pos.rs rename to crates/cfxcore/core/src/pos/pos.rs index e564d96295..189f6fdfb5 100644 --- a/core/src/pos/pos.rs +++ b/crates/cfxcore/core/src/pos/pos.rs @@ -6,6 +6,7 @@ // See http://www.gnu.org/licenses/ use crate::{ + genesis_block::GenesisPosState, pos::{ consensus::{ consensus_provider::start_consensus, @@ -26,9 +27,9 @@ use crate::{ }, state_sync::bootstrapper::StateSyncBootstrapper, }, - spec::genesis::GenesisPosState, sync::ProtocolConfiguration, }; + use cached_pos_ledger_db::CachedPosLedgerDB; use consensus_types::db::FakeLedgerBlockDB; use diem_config::{config::NodeConfig, utils::get_genesis_txn}; @@ -41,7 +42,7 @@ use diem_types::{ validator_config::{ConsensusPublicKey, ConsensusVRFPublicKey}, PeerId, }; -use executor::{db_bootstrapper::maybe_bootstrap, vm::FakeVM, Executor}; +use executor::{db_bootstrapper::maybe_bootstrap, vm::PosVM, Executor}; use executor_types::ChunkExecutor; use futures::{ channel::{ @@ -93,8 +94,7 @@ pub fn start_pos_consensus( mempool_network_receiver: MemPoolNetworkReceivers, test_command_receiver: channel::Receiver, hsb_protocol: Arc, -) -> PosDropHandle -{ +) -> PosDropHandle { crash_handler::setup_panic_handler(); let mut logger = diem_logger::Logger::new(); @@ -173,7 +173,7 @@ fn setup_metrics(peer_id: PeerId, config: &NodeConfig) { } fn setup_chunk_executor(db: DbReaderWriter) -> Box { - Box::new(Executor::::new( + Box::new(Executor::::new( Arc::new(CachedPosLedgerDB::new(db)), Arc::new(FakePowHandler {}), Arc::new(FakeLedgerBlockDB {}), @@ -189,8 +189,7 @@ pub fn setup_pos_environment( mempool_network_receiver: MemPoolNetworkReceivers, test_command_receiver: channel::Receiver, hsb_protocol: Arc, -) -> PosDropHandle -{ +) -> PosDropHandle { // TODO(lpl): Handle port conflict. // let metrics_port = node_config.debug_interface.metrics_server_port; // let metric_host = node_config.debug_interface.address.clone(); @@ -222,7 +221,7 @@ pub fn setup_pos_environment( let genesis_waypoint = node_config.base.waypoint.genesis_waypoint(); // if there's genesis txn and waypoint, commit it if the result matches. if let Some(genesis) = get_genesis_txn(&node_config) { - maybe_bootstrap::( + maybe_bootstrap::( &db_rw, genesis, genesis_waypoint, diff --git a/core/src/pos/pow_handler.rs b/crates/cfxcore/core/src/pos/pow_handler.rs similarity index 97% rename from core/src/pos/pow_handler.rs rename to crates/cfxcore/core/src/pos/pow_handler.rs index 9f7872af40..6a7bd11a1b 100644 --- a/core/src/pos/pow_handler.rs +++ b/crates/cfxcore/core/src/pos/pow_handler.rs @@ -2,12 +2,10 @@ // Conflux is free software and distributed under GNU General Public License. // See http://www.gnu.org/licenses/ -use crate::{ - executive::internal_contract::decode_register_info, - pos::consensus::ConsensusDB, ConsensusGraph, -}; +use crate::{pos::consensus::ConsensusDB, ConsensusGraph}; use anyhow::{anyhow, bail, Result}; use async_trait::async_trait; +use cfx_executor::internal_contract::decode_register_info; use cfx_parameters::internal_contract_addresses::POS_REGISTER_CONTRACT_ADDRESS; use cfx_types::H256; use diem_types::block_info::PivotBlockDecision; @@ -66,8 +64,7 @@ impl PowHandler { fn validate_proposal_pivot_decision_impl( pow_consensus: Arc, parent_decision: &H256, me_decision: &H256, - ) -> bool - { + ) -> bool { pow_consensus .inner .read() @@ -77,8 +74,7 @@ impl PowHandler { fn get_staking_events_impl( pow_consensus: Arc, parent_decision: H256, me_decision: H256, - ) -> Result> - { + ) -> Result> { // We only call this for committed blocks, so it is guaranteed that // `parent_decision` is an ancestor of `me_decision`. if parent_decision == me_decision { @@ -171,8 +167,7 @@ impl PowInterface for PowHandler { fn get_staking_events( &self, parent_height: u64, me_height: u64, parent_decision: H256, me_decision: H256, - ) -> Result> - { + ) -> Result> { let pow_consensus = self.pow_consensus.read().clone().and_then(|c| c.upgrade()); if pow_consensus.is_none() { diff --git a/core/src/pos/protocol/message/block_retrieval.rs b/crates/cfxcore/core/src/pos/protocol/message/block_retrieval.rs similarity index 100% rename from core/src/pos/protocol/message/block_retrieval.rs rename to crates/cfxcore/core/src/pos/protocol/message/block_retrieval.rs diff --git a/core/src/pos/protocol/message/block_retrieval_response.rs b/crates/cfxcore/core/src/pos/protocol/message/block_retrieval_response.rs similarity index 100% rename from core/src/pos/protocol/message/block_retrieval_response.rs rename to crates/cfxcore/core/src/pos/protocol/message/block_retrieval_response.rs diff --git a/core/src/pos/protocol/message/consensus_msg.rs b/crates/cfxcore/core/src/pos/protocol/message/consensus_msg.rs similarity index 100% rename from core/src/pos/protocol/message/consensus_msg.rs rename to crates/cfxcore/core/src/pos/protocol/message/consensus_msg.rs diff --git a/core/src/pos/protocol/message/epoch_change.rs b/crates/cfxcore/core/src/pos/protocol/message/epoch_change.rs similarity index 100% rename from core/src/pos/protocol/message/epoch_change.rs rename to crates/cfxcore/core/src/pos/protocol/message/epoch_change.rs diff --git a/core/src/pos/protocol/message/epoch_retrieval.rs b/crates/cfxcore/core/src/pos/protocol/message/epoch_retrieval.rs similarity index 100% rename from core/src/pos/protocol/message/epoch_retrieval.rs rename to crates/cfxcore/core/src/pos/protocol/message/epoch_retrieval.rs diff --git a/core/src/pos/protocol/message/mempool_sync_msg.rs b/crates/cfxcore/core/src/pos/protocol/message/mempool_sync_msg.rs similarity index 100% rename from core/src/pos/protocol/message/mempool_sync_msg.rs rename to crates/cfxcore/core/src/pos/protocol/message/mempool_sync_msg.rs diff --git a/core/src/pos/protocol/message/mod.rs b/crates/cfxcore/core/src/pos/protocol/message/mod.rs similarity index 100% rename from core/src/pos/protocol/message/mod.rs rename to crates/cfxcore/core/src/pos/protocol/message/mod.rs diff --git a/core/src/pos/protocol/message/proposal.rs b/crates/cfxcore/core/src/pos/protocol/message/proposal.rs similarity index 100% rename from core/src/pos/protocol/message/proposal.rs rename to crates/cfxcore/core/src/pos/protocol/message/proposal.rs diff --git a/core/src/pos/protocol/message/sync_info.rs b/crates/cfxcore/core/src/pos/protocol/message/sync_info.rs similarity index 100% rename from core/src/pos/protocol/message/sync_info.rs rename to crates/cfxcore/core/src/pos/protocol/message/sync_info.rs diff --git a/core/src/pos/protocol/message/vote.rs b/crates/cfxcore/core/src/pos/protocol/message/vote.rs similarity index 100% rename from core/src/pos/protocol/message/vote.rs rename to crates/cfxcore/core/src/pos/protocol/message/vote.rs diff --git a/core/src/pos/protocol/mod.rs b/crates/cfxcore/core/src/pos/protocol/mod.rs similarity index 100% rename from core/src/pos/protocol/mod.rs rename to crates/cfxcore/core/src/pos/protocol/mod.rs diff --git a/core/src/pos/protocol/network_event.rs b/crates/cfxcore/core/src/pos/protocol/network_event.rs similarity index 100% rename from core/src/pos/protocol/network_event.rs rename to crates/cfxcore/core/src/pos/protocol/network_event.rs diff --git a/core/src/pos/protocol/network_sender.rs b/crates/cfxcore/core/src/pos/protocol/network_sender.rs similarity index 99% rename from core/src/pos/protocol/network_sender.rs rename to crates/cfxcore/core/src/pos/protocol/network_sender.rs index c38e47c90b..7c08106304 100644 --- a/core/src/pos/protocol/network_sender.rs +++ b/crates/cfxcore/core/src/pos/protocol/network_sender.rs @@ -67,8 +67,7 @@ impl NetworkSender { pub fn send_to_many( &mut self, recipients: impl Iterator, msg: &dyn Message, - ) -> Result<(), anyhow::Error> - { + ) -> Result<(), anyhow::Error> { for recipient in recipients { self.send_to(recipient, msg)?; } diff --git a/core/src/pos/protocol/request_manager/mod.rs b/crates/cfxcore/core/src/pos/protocol/request_manager/mod.rs similarity index 99% rename from core/src/pos/protocol/request_manager/mod.rs rename to crates/cfxcore/core/src/pos/protocol/request_manager/mod.rs index f58369f9d9..19807a2d5c 100644 --- a/core/src/pos/protocol/request_manager/mod.rs +++ b/crates/cfxcore/core/src/pos/protocol/request_manager/mod.rs @@ -46,8 +46,7 @@ impl RequestManager { pub async fn unary_rpc<'a>( &'a self, io: &'a dyn NetworkContext, recipient: Option, mut request: Box, - ) -> impl Future, Error>> + 'a - { + ) -> impl Future, Error>> + 'a { async move { // ask network to fulfill rpc request let (res_tx, res_rx) = oneshot::channel(); @@ -66,8 +65,7 @@ impl RequestManager { pub fn request_with_delay( &self, io: &dyn NetworkContext, mut request: Box, peer: Option, delay: Option, - ) - { + ) { // increase delay for resent request. let (cur_delay, next_delay) = match delay { Some(d) => (d, d + *REQUEST_START_WAITING_TIME), diff --git a/core/src/pos/protocol/request_manager/request_handler.rs b/crates/cfxcore/core/src/pos/protocol/request_manager/request_handler.rs similarity index 96% rename from core/src/pos/protocol/request_manager/request_handler.rs rename to crates/cfxcore/core/src/pos/protocol/request_manager/request_handler.rs index 751c18e28a..ab7aea0945 100644 --- a/core/src/pos/protocol/request_manager/request_handler.rs +++ b/crates/cfxcore/core/src/pos/protocol/request_manager/request_handler.rs @@ -60,10 +60,9 @@ impl RequestHandler { // Match request for given response. // Could return the following error: - // 1. Error return from peer.match_request(): - // No need to let caller handle request resending; - // 2. UnknownPeer: - // No need to let caller handle request resending; + // 1. Error return from peer.match_request(): No need to let caller handle + // request resending; + // 2. UnknownPeer: No need to let caller handle request resending; pub fn match_request( &self, io: &dyn NetworkContext, peer_id: &NodeId, request_id: u64, ) -> Result { @@ -86,8 +85,7 @@ impl RequestHandler { pub fn send_request( &self, io: &dyn NetworkContext, peer: Option, mut request: Box, delay: Option, - ) -> Result<(), Box> - { + ) -> Result<(), Box> { let peer = match peer { Some(peer) => peer, None => return Err(request), @@ -274,8 +272,7 @@ impl RequestContainer { pub fn append_inflight_request( &mut self, request_id: u64, message: RequestMessage, timed_req: Arc, - ) - { + ) { self.inflight_requests.insert( request_id, SynchronizationPeerRequest { message, timed_req }, @@ -310,18 +307,15 @@ impl RequestContainer { // Match request with given response. // Could return the following error: - // 1. RequestNotFound: - // In this case, no request is matched, so NO need to - // handle the resending of the request for caller; - // 2. Error from send_message(): - // This also does NOT introduce needs to handle request - // resending for caller; + // 1. RequestNotFound: In this case, no request is matched, so NO need to + // handle the resending of the request for caller; + // 2. Error from send_message(): This also does NOT introduce needs to + // handle request resending for caller; pub fn match_request( &mut self, io: &dyn NetworkContext, request_id: u64, requests_queue: &mut BinaryHeap>, protocol_config: &ProtocolConfiguration, - ) -> Result - { + ) -> Result { let removed_req = self.remove_inflight_request(request_id); if let Some(removed_req) = removed_req { removed_req @@ -461,8 +455,7 @@ impl TimedSyncRequests { pub fn from_request( peer_id: NodeId, request_id: u64, msg: &RequestMessage, conf: &ProtocolConfiguration, is_send_error: bool, - ) -> TimedSyncRequests - { + ) -> TimedSyncRequests { let timeout = if is_send_error { Duration::from_secs(1) } else { diff --git a/core/src/pos/protocol/sync_protocol.rs b/crates/cfxcore/core/src/pos/protocol/sync_protocol.rs similarity index 99% rename from core/src/pos/protocol/sync_protocol.rs rename to crates/cfxcore/core/src/pos/protocol/sync_protocol.rs index 2325a741bd..4e5def47ad 100644 --- a/core/src/pos/protocol/sync_protocol.rs +++ b/crates/cfxcore/core/src/pos/protocol/sync_protocol.rs @@ -59,8 +59,7 @@ impl PeerState { pub fn new( id: NodeId, peer_hash: H256, pos_public_key: Option<(ConsensusPublicKey, ConsensusVRFPublicKey)>, - ) -> Self - { + ) -> Self { Self { id, peer_hash, @@ -71,8 +70,7 @@ impl PeerState { pub fn set_pos_public_key( &mut self, pos_public_key: Option<(ConsensusPublicKey, ConsensusVRFPublicKey)>, - ) - { + ) { self.pos_public_key = pos_public_key } @@ -92,8 +90,7 @@ impl Peers { pub fn insert( &self, peer: H256, id: NodeId, pos_public_key: Option<(ConsensusPublicKey, ConsensusVRFPublicKey)>, - ) - { + ) { self.0.write().entry(peer).or_insert(Arc::new(RwLock::new( PeerState::new(id, peer, pos_public_key), ))); @@ -188,8 +185,7 @@ impl HotStuffSynchronizationProtocol { own_node_hash: H256, consensus_network_task: ConsensusNetworkTask, mempool_network_task: MempoolNetworkTask, protocol_config: ProtocolConfiguration, - ) -> Self - { + ) -> Self { let request_manager = Arc::new(RequestManager::new(&protocol_config)); HotStuffSynchronizationProtocol { protocol_config, @@ -206,8 +202,7 @@ impl HotStuffSynchronizationProtocol { protocol_config: ProtocolConfiguration, own_node_hash: H256, consensus_network_task: ConsensusNetworkTask, mempool_network_task: MempoolNetworkTask, peers: Arc, - ) -> Self - { + ) -> Self { let request_manager = Arc::new(RequestManager::new(&protocol_config)); HotStuffSynchronizationProtocol { protocol_config, @@ -250,8 +245,7 @@ impl HotStuffSynchronizationProtocol { fn simultaneous_dial_tie_breaking( own_peer_id: H256, remote_peer_id: H256, existing_origin: bool, new_origin: bool, - ) -> bool - { + ) -> bool { match (existing_origin, new_origin) { // If the remote dials while an existing connection is open, the // older connection is dropped. @@ -396,8 +390,7 @@ impl HotStuffSynchronizationProtocol { fn dispatch_message( &self, io: &dyn NetworkContext, peer: &NodeId, msg_id: MsgId, msg: &[u8], - ) -> Result<(), Error> - { + ) -> Result<(), Error> { trace!("Dispatching message: peer={:?}, msg_id={:?}", peer, msg_id); let peer_hash = if !io.is_peer_self(peer) { if *peer == NodeId::default() { @@ -521,8 +514,7 @@ impl NetworkProtocolHandler for HotStuffSynchronizationProtocol { &self, io: &dyn NetworkContext, node_id: &NodeId, _peer_protocol_version: ProtocolVersion, pos_public_key: Option<(ConsensusPublicKey, ConsensusVRFPublicKey)>, - ) - { + ) { // TODO(linxi): maintain peer protocol version let new_originated = io.get_peer_connection_origin(node_id); if new_originated.is_none() { diff --git a/core/src/pos/secure/net/Cargo.toml b/crates/cfxcore/core/src/pos/secure/net/Cargo.toml similarity index 100% rename from core/src/pos/secure/net/Cargo.toml rename to crates/cfxcore/core/src/pos/secure/net/Cargo.toml diff --git a/core/src/pos/secure/net/src/lib.rs b/crates/cfxcore/core/src/pos/secure/net/src/lib.rs similarity index 99% rename from core/src/pos/secure/net/src/lib.rs rename to crates/cfxcore/core/src/pos/secure/net/src/lib.rs index 2486c8aaba..a1822bba0a 100644 --- a/core/src/pos/secure/net/src/lib.rs +++ b/crates/cfxcore/core/src/pos/secure/net/src/lib.rs @@ -132,8 +132,7 @@ impl MethodResult { fn increment_counter( service: &'static str, mode: NetworkMode, method: Method, result: MethodResult, -) -{ +) { EVENT_COUNTER .with_label_values(&[ service, diff --git a/core/src/pos/secure/push-metrics/Cargo.toml b/crates/cfxcore/core/src/pos/secure/push-metrics/Cargo.toml similarity index 100% rename from core/src/pos/secure/push-metrics/Cargo.toml rename to crates/cfxcore/core/src/pos/secure/push-metrics/Cargo.toml diff --git a/core/src/pos/secure/push-metrics/src/lib.rs b/crates/cfxcore/core/src/pos/secure/push-metrics/src/lib.rs similarity index 99% rename from core/src/pos/secure/push-metrics/src/lib.rs rename to crates/cfxcore/core/src/pos/secure/push-metrics/src/lib.rs index 241f830dc1..3ef6749066 100644 --- a/core/src/pos/secure/push-metrics/src/lib.rs +++ b/crates/cfxcore/core/src/pos/secure/push-metrics/src/lib.rs @@ -60,8 +60,7 @@ impl MetricsPusher { fn worker( quit_receiver: mpsc::Receiver<()>, push_metrics_endpoint: String, push_metrics_frequency_secs: u64, - ) - { + ) { while quit_receiver .recv_timeout(Duration::from_secs(push_metrics_frequency_secs)) .is_err() diff --git a/core/src/pos/secure/storage/Cargo.toml b/crates/cfxcore/core/src/pos/secure/storage/Cargo.toml similarity index 96% rename from core/src/pos/secure/storage/Cargo.toml rename to crates/cfxcore/core/src/pos/secure/storage/Cargo.toml index c9c587676b..1f96da0577 100644 --- a/core/src/pos/secure/storage/Cargo.toml +++ b/crates/cfxcore/core/src/pos/secure/storage/Cargo.toml @@ -26,7 +26,7 @@ diem-logger = { path = "../../common/logger" } diem-temppath = { path = "../../common/temppath" } diem-time-service = { path = "../../common/time-service" } diem-vault-client = { path = "vault" } -diem-types = {path = "../../types"} +diem-types = {path = "../../types" } [dev-dependencies] diem-crypto = { path = "../../crypto/crypto", features = ["fuzzing"] } diff --git a/core/src/pos/secure/storage/README.md b/crates/cfxcore/core/src/pos/secure/storage/README.md similarity index 100% rename from core/src/pos/secure/storage/README.md rename to crates/cfxcore/core/src/pos/secure/storage/README.md diff --git a/core/src/pos/secure/storage/github/Cargo.toml b/crates/cfxcore/core/src/pos/secure/storage/github/Cargo.toml similarity index 100% rename from core/src/pos/secure/storage/github/Cargo.toml rename to crates/cfxcore/core/src/pos/secure/storage/github/Cargo.toml diff --git a/core/src/pos/secure/storage/github/src/lib.rs b/crates/cfxcore/core/src/pos/secure/storage/github/src/lib.rs similarity index 100% rename from core/src/pos/secure/storage/github/src/lib.rs rename to crates/cfxcore/core/src/pos/secure/storage/github/src/lib.rs diff --git a/core/src/pos/secure/storage/src/crypto_kv_storage.rs b/crates/cfxcore/core/src/pos/secure/storage/src/crypto_kv_storage.rs similarity index 100% rename from core/src/pos/secure/storage/src/crypto_kv_storage.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/crypto_kv_storage.rs diff --git a/core/src/pos/secure/storage/src/crypto_storage.rs b/crates/cfxcore/core/src/pos/secure/storage/src/crypto_storage.rs similarity index 100% rename from core/src/pos/secure/storage/src/crypto_storage.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/crypto_storage.rs diff --git a/core/src/pos/secure/storage/src/error.rs b/crates/cfxcore/core/src/pos/secure/storage/src/error.rs similarity index 100% rename from core/src/pos/secure/storage/src/error.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/error.rs diff --git a/core/src/pos/secure/storage/src/github.rs b/crates/cfxcore/core/src/pos/secure/storage/src/github.rs similarity index 100% rename from core/src/pos/secure/storage/src/github.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/github.rs diff --git a/core/src/pos/secure/storage/src/in_memory.rs b/crates/cfxcore/core/src/pos/secure/storage/src/in_memory.rs similarity index 100% rename from core/src/pos/secure/storage/src/in_memory.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/in_memory.rs diff --git a/core/src/pos/secure/storage/src/kv_storage.rs b/crates/cfxcore/core/src/pos/secure/storage/src/kv_storage.rs similarity index 100% rename from core/src/pos/secure/storage/src/kv_storage.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/kv_storage.rs diff --git a/core/src/pos/secure/storage/src/lib.rs b/crates/cfxcore/core/src/pos/secure/storage/src/lib.rs similarity index 100% rename from core/src/pos/secure/storage/src/lib.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/lib.rs diff --git a/core/src/pos/secure/storage/src/namespaced_storage.rs b/crates/cfxcore/core/src/pos/secure/storage/src/namespaced_storage.rs similarity index 100% rename from core/src/pos/secure/storage/src/namespaced_storage.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/namespaced_storage.rs diff --git a/core/src/pos/secure/storage/src/on_disk.rs b/crates/cfxcore/core/src/pos/secure/storage/src/on_disk.rs similarity index 100% rename from core/src/pos/secure/storage/src/on_disk.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/on_disk.rs diff --git a/core/src/pos/secure/storage/src/policy.rs b/crates/cfxcore/core/src/pos/secure/storage/src/policy.rs similarity index 100% rename from core/src/pos/secure/storage/src/policy.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/policy.rs diff --git a/core/src/pos/secure/storage/src/storage.rs b/crates/cfxcore/core/src/pos/secure/storage/src/storage.rs similarity index 100% rename from core/src/pos/secure/storage/src/storage.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/storage.rs diff --git a/core/src/pos/secure/storage/src/tests/github.rs b/crates/cfxcore/core/src/pos/secure/storage/src/tests/github.rs similarity index 100% rename from core/src/pos/secure/storage/src/tests/github.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/tests/github.rs diff --git a/core/src/pos/secure/storage/src/tests/in_memory.rs b/crates/cfxcore/core/src/pos/secure/storage/src/tests/in_memory.rs similarity index 100% rename from core/src/pos/secure/storage/src/tests/in_memory.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/tests/in_memory.rs diff --git a/core/src/pos/secure/storage/src/tests/mod.rs b/crates/cfxcore/core/src/pos/secure/storage/src/tests/mod.rs similarity index 100% rename from core/src/pos/secure/storage/src/tests/mod.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/tests/mod.rs diff --git a/core/src/pos/secure/storage/src/tests/on_disk.rs b/crates/cfxcore/core/src/pos/secure/storage/src/tests/on_disk.rs similarity index 100% rename from core/src/pos/secure/storage/src/tests/on_disk.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/tests/on_disk.rs diff --git a/core/src/pos/secure/storage/src/tests/suite.rs b/crates/cfxcore/core/src/pos/secure/storage/src/tests/suite.rs similarity index 100% rename from core/src/pos/secure/storage/src/tests/suite.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/tests/suite.rs diff --git a/core/src/pos/secure/storage/src/tests/vault.rs b/crates/cfxcore/core/src/pos/secure/storage/src/tests/vault.rs similarity index 99% rename from core/src/pos/secure/storage/src/tests/vault.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/tests/vault.rs index 9e44ed3dea..ecd4815742 100644 --- a/core/src/pos/secure/storage/src/tests/vault.rs +++ b/crates/cfxcore/core/src/pos/secure/storage/src/tests/vault.rs @@ -105,8 +105,7 @@ fn create_vault_with_namespace(namespace: Option) -> VaultStorage { fn create_vault_storage( token: String, namespace: Option, renew_ttl_secs: Option, use_cas: bool, -) -> VaultStorage -{ +) -> VaultStorage { VaultStorage::new( dev::test_host(), token, diff --git a/core/src/pos/secure/storage/src/vault.rs b/crates/cfxcore/core/src/pos/secure/storage/src/vault.rs similarity index 99% rename from core/src/pos/secure/storage/src/vault.rs rename to crates/cfxcore/core/src/pos/secure/storage/src/vault.rs index fdce88b436..5f3ebcdada 100644 --- a/core/src/pos/secure/storage/src/vault.rs +++ b/crates/cfxcore/core/src/pos/secure/storage/src/vault.rs @@ -51,8 +51,7 @@ impl VaultStorage { certificate: Option, renew_ttl_secs: Option, use_cas: bool, connection_timeout_ms: Option, response_timeout_ms: Option, - ) -> Self - { + ) -> Self { Self { client: Client::new( host, @@ -173,8 +172,7 @@ impl VaultStorage { pub fn set_policy( &self, policy_name: &str, engine: &VaultEngine, key: &str, capabilities: &[Capability], - ) -> Result<(), Error> - { + ) -> Result<(), Error> { let policy_name = self.name(policy_name, engine); let mut vault_policy = diff --git a/core/src/pos/secure/storage/vault/Cargo.toml b/crates/cfxcore/core/src/pos/secure/storage/vault/Cargo.toml similarity index 96% rename from core/src/pos/secure/storage/vault/Cargo.toml rename to crates/cfxcore/core/src/pos/secure/storage/vault/Cargo.toml index c0a8d0fca5..d85e620f35 100644 --- a/core/src/pos/secure/storage/vault/Cargo.toml +++ b/crates/cfxcore/core/src/pos/secure/storage/vault/Cargo.toml @@ -22,7 +22,7 @@ ureq = { version = "1.5.4", features = ["json", "native-tls"], default-features diem-crypto = { path = "../../../crypto/crypto" } diem-proptest-helpers = { path = "../../../common/proptest-helpers", optional = true } -diem-types = { path = "../../../types"} +diem-types = { path = "../../../types" } [dev-dependencies] proptest = "1.0.0" diff --git a/core/src/pos/secure/storage/vault/src/dev.rs b/crates/cfxcore/core/src/pos/secure/storage/vault/src/dev.rs similarity index 100% rename from core/src/pos/secure/storage/vault/src/dev.rs rename to crates/cfxcore/core/src/pos/secure/storage/vault/src/dev.rs diff --git a/core/src/pos/secure/storage/vault/src/fuzzing.rs b/crates/cfxcore/core/src/pos/secure/storage/vault/src/fuzzing.rs similarity index 100% rename from core/src/pos/secure/storage/vault/src/fuzzing.rs rename to crates/cfxcore/core/src/pos/secure/storage/vault/src/fuzzing.rs diff --git a/core/src/pos/secure/storage/vault/src/lib.rs b/crates/cfxcore/core/src/pos/secure/storage/vault/src/lib.rs similarity index 99% rename from core/src/pos/secure/storage/vault/src/lib.rs rename to crates/cfxcore/core/src/pos/secure/storage/vault/src/lib.rs index 7aecb9d916..65ca8c59e3 100644 --- a/core/src/pos/secure/storage/vault/src/lib.rs +++ b/crates/cfxcore/core/src/pos/secure/storage/vault/src/lib.rs @@ -134,8 +134,7 @@ impl Client { pub fn new( host: String, token: String, ca_certificate: Option, connection_timeout_ms: Option, response_timeout_ms: Option, - ) -> Self - { + ) -> Self { let mut tls_builder = native_tls::TlsConnector::builder(); tls_builder.min_protocol_version(Some(native_tls::Protocol::Tlsv12)); if let Some(certificate) = ca_certificate { diff --git a/core/src/pos/state_sync/bootstrapper.rs b/crates/cfxcore/core/src/pos/state_sync/bootstrapper.rs similarity index 98% rename from core/src/pos/state_sync/bootstrapper.rs rename to crates/cfxcore/core/src/pos/state_sync/bootstrapper.rs index 5454a62c3f..a74f0db210 100644 --- a/core/src/pos/state_sync/bootstrapper.rs +++ b/crates/cfxcore/core/src/pos/state_sync/bootstrapper.rs @@ -37,8 +37,7 @@ impl StateSyncBootstrapper { storage: Arc, executor: Box, node_config: &NodeConfig, waypoint: Waypoint, reconfig_event_subscriptions: Vec, - ) -> Self - { + ) -> Self { let runtime = Builder::new_multi_thread() .thread_name("state-sync") .enable_all() @@ -64,8 +63,7 @@ impl StateSyncBootstrapper { diem_mempool::CommitNotification, >, node_config: &NodeConfig, waypoint: Waypoint, executor_proxy: E, - ) -> Self - { + ) -> Self { let (coordinator_sender, coordinator_receiver) = mpsc::unbounded(); let initial_state = executor_proxy .get_local_storage_state() diff --git a/core/src/pos/state_sync/chunk_request.rs b/crates/cfxcore/core/src/pos/state_sync/chunk_request.rs similarity index 99% rename from core/src/pos/state_sync/chunk_request.rs rename to crates/cfxcore/core/src/pos/state_sync/chunk_request.rs index fb9f163737..c36b82fc88 100644 --- a/core/src/pos/state_sync/chunk_request.rs +++ b/crates/cfxcore/core/src/pos/state_sync/chunk_request.rs @@ -122,8 +122,7 @@ impl GetChunkRequest { pub fn new( known_version: Version, current_epoch: u64, limit: u64, target: TargetType, - ) -> Self - { + ) -> Self { Self { known_version, current_epoch, diff --git a/core/src/pos/state_sync/chunk_response.rs b/crates/cfxcore/core/src/pos/state_sync/chunk_response.rs similarity index 99% rename from core/src/pos/state_sync/chunk_response.rs rename to crates/cfxcore/core/src/pos/state_sync/chunk_response.rs index 6c4a283d92..2c7504dbb9 100644 --- a/core/src/pos/state_sync/chunk_response.rs +++ b/crates/cfxcore/core/src/pos/state_sync/chunk_response.rs @@ -78,8 +78,7 @@ impl GetChunkResponse { pub fn new( response_li: ResponseLedgerInfo, txn_list_with_proof: TransactionListWithProof, - ) -> Self - { + ) -> Self { Self { response_li, txn_list_with_proof, diff --git a/core/src/pos/state_sync/client.rs b/crates/cfxcore/core/src/pos/state_sync/client.rs similarity index 98% rename from core/src/pos/state_sync/client.rs rename to crates/cfxcore/core/src/pos/state_sync/client.rs index c80f7a360c..0965bab8a9 100644 --- a/core/src/pos/state_sync/client.rs +++ b/crates/cfxcore/core/src/pos/state_sync/client.rs @@ -60,8 +60,7 @@ impl StateSyncClient { pub fn new( coordinator_sender: mpsc::UnboundedSender, commit_timeout_ms: u64, - ) -> Self - { + ) -> Self { Self { coordinator_sender, commit_timeout_ms, @@ -94,8 +93,7 @@ impl StateSyncClient { pub fn commit( &self, committed_txns: Vec, reconfig_events: Vec, - ) -> impl Future> - { + ) -> impl Future> { let mut sender = self.coordinator_sender.clone(); let (cb_sender, cb_receiver) = oneshot::channel(); diff --git a/core/src/pos/state_sync/coordinator.rs b/crates/cfxcore/core/src/pos/state_sync/coordinator.rs similarity index 99% rename from core/src/pos/state_sync/coordinator.rs rename to crates/cfxcore/core/src/pos/state_sync/coordinator.rs index 73e1ca378d..4a698a170f 100644 --- a/core/src/pos/state_sync/coordinator.rs +++ b/crates/cfxcore/core/src/pos/state_sync/coordinator.rs @@ -106,8 +106,7 @@ impl StateSyncCoordinator { /* network_senders: HashMap, */ node_config: &NodeConfig, waypoint: Waypoint, executor_proxy: T, initial_state: SyncState, - ) -> Result - { + ) -> Result { diem_info!(LogSchema::event_log( LogEntry::Waypoint, LogEvent::Initialize @@ -161,8 +160,7 @@ impl StateSyncCoordinator { mut self, /* network_handles: Vec<(NodeNetworkId, StateSyncSender, * StateSyncEvents)>, */ - ) - { + ) { diem_info!(LogSchema::new(LogEntry::RuntimeStart)); let mut interval = IntervalStream::new(interval( Duration::from_millis(self.config.tick_interval_ms), @@ -426,8 +424,7 @@ impl StateSyncCoordinator { fn notify_consensus_of_commit_response( &self, commit_response: CommitResponse, callback: Option>>, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { if let Some(callback) = callback { if let Err(error) = callback.send(Ok(commit_response)) { counters::COMMIT_FLOW_FAIL @@ -453,8 +450,7 @@ impl StateSyncCoordinator { commit_callback: Option>>, reconfiguration_events: Vec, chunk_sender: Option<&PeerNetworkId>, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { diem_debug!( "process_commit_notification: {} events", reconfiguration_events.len() @@ -837,8 +833,7 @@ impl StateSyncCoordinator { ) -> Result< (LedgerInfoWithSignatures, Option), Error, - > - { + > { // If the request's epoch is in the past, `target_li` will be set to the // end-of-epoch LI for that epoch let target_li = @@ -862,8 +857,7 @@ impl StateSyncCoordinator { fn process_request_for_waypoint( &mut self, peer: PeerNetworkId, request: GetChunkRequest, waypoint_version: Version, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { let mut limit = std::cmp::min(request.limit, self.config.max_chunk_limit); if self.local_state.committed_version() < waypoint_version { @@ -926,8 +920,7 @@ impl StateSyncCoordinator { fn deliver_chunk( &mut self, peer: PeerNetworkId, known_version: u64, response_li: ResponseLedgerInfo, limit: u64, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { /* let txns = self.executor_proxy.get_chunk( known_version, @@ -1222,8 +1215,7 @@ impl StateSyncCoordinator { fn verify_response_with_target_and_highest( &mut self, target_li: &LedgerInfoWithSignatures, highest_li: &Option, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { if !self.is_initialized() { return Err(Error::ReceivedWrongChunkType( "Received a progressive ledger info, but we're not initialized!".into(), @@ -1263,8 +1255,7 @@ impl StateSyncCoordinator { fn verify_response_with_waypoint_li( &mut self, waypoint_li: &LedgerInfoWithSignatures, end_of_epoch_li: &Option, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { if self.is_initialized() || self.sync_request.is_some() { return Err(Error::ReceivedWrongChunkType( "Received a waypoint ledger info, but we're already initialized!".into(), @@ -1320,8 +1311,7 @@ impl StateSyncCoordinator { fn calculate_new_known_version_and_epoch( &mut self, txn_list_with_proof: TransactionListWithProof, ledger_info: Option, - ) -> Result<(u64, u64), Error> - { + ) -> Result<(u64, u64), Error> { let new_version = self .local_state .synced_version() @@ -1558,8 +1548,7 @@ impl StateSyncCoordinator { &mut self, txn_list_with_proof: TransactionListWithProof, target: LedgerInfoWithSignatures, intermediate_end_of_epoch_li: Option, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { let target_epoch = target.ledger_info().epoch(); let target_version = target.ledger_info().version(); let local_epoch = self.local_state.committed_epoch(); @@ -1601,8 +1590,8 @@ impl StateSyncCoordinator { /// request was sent. fn check_progress(&mut self) -> Result<(), Error> { if self.is_consensus_executing() { - return Ok(()); // No need to check progress or issue any requests (consensus is - // running). + return Ok(()); // No need to check progress or issue any requests + // (consensus is running). } // Check if the sync request has timed out (i.e., if we aren't @@ -1736,8 +1725,7 @@ impl StateSyncCoordinator { fn deliver_subscription( &mut self, peer: PeerNetworkId, request_info: PendingRequestInfo, local_version: u64, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { let (target_li, highest_li) = self.calculate_target_and_highest_li( request_info.request_epoch, request_info.target_li, diff --git a/core/src/pos/state_sync/counters.rs b/crates/cfxcore/core/src/pos/state_sync/counters.rs similarity index 100% rename from core/src/pos/state_sync/counters.rs rename to crates/cfxcore/core/src/pos/state_sync/counters.rs diff --git a/core/src/pos/state_sync/error.rs b/crates/cfxcore/core/src/pos/state_sync/error.rs similarity index 100% rename from core/src/pos/state_sync/error.rs rename to crates/cfxcore/core/src/pos/state_sync/error.rs diff --git a/core/src/pos/state_sync/executor_proxy.rs b/crates/cfxcore/core/src/pos/state_sync/executor_proxy.rs similarity index 99% rename from core/src/pos/state_sync/executor_proxy.rs rename to crates/cfxcore/core/src/pos/state_sync/executor_proxy.rs index 6fef85431a..87345981c0 100644 --- a/core/src/pos/state_sync/executor_proxy.rs +++ b/crates/cfxcore/core/src/pos/state_sync/executor_proxy.rs @@ -74,8 +74,7 @@ impl ExecutorProxy { pub(crate) fn new( storage: Arc, executor: Box, mut reconfig_subscriptions: Vec, - ) -> Self - { + ) -> Self { // TODO(lpl): Double check the `None` case here. let on_chain_configs = if let Ok(Some(startup_info)) = storage.get_startup_info(false) @@ -227,8 +226,7 @@ impl ExecutorProxyTrait for ExecutorProxy { &mut self, txn_list_with_proof: TransactionListWithProof, verified_target_li: LedgerInfoWithSignatures, intermediate_end_of_epoch_li: Option, - ) -> Result<(), Error> - { + ) -> Result<(), Error> { // track chunk execution time let timer = counters::EXECUTE_CHUNK_DURATION.start_timer(); let reconfig_events = self diff --git a/core/src/pos/state_sync/fuzzing.rs b/crates/cfxcore/core/src/pos/state_sync/fuzzing.rs similarity index 100% rename from core/src/pos/state_sync/fuzzing.rs rename to crates/cfxcore/core/src/pos/state_sync/fuzzing.rs diff --git a/core/src/pos/state_sync/logging.rs b/crates/cfxcore/core/src/pos/state_sync/logging.rs similarity index 100% rename from core/src/pos/state_sync/logging.rs rename to crates/cfxcore/core/src/pos/state_sync/logging.rs diff --git a/core/src/pos/state_sync/mod.rs b/crates/cfxcore/core/src/pos/state_sync/mod.rs similarity index 100% rename from core/src/pos/state_sync/mod.rs rename to crates/cfxcore/core/src/pos/state_sync/mod.rs diff --git a/core/src/pos/state_sync/network.rs b/crates/cfxcore/core/src/pos/state_sync/network.rs similarity index 100% rename from core/src/pos/state_sync/network.rs rename to crates/cfxcore/core/src/pos/state_sync/network.rs diff --git a/core/src/pos/state_sync/request_manager.rs b/crates/cfxcore/core/src/pos/state_sync/request_manager.rs similarity index 100% rename from core/src/pos/state_sync/request_manager.rs rename to crates/cfxcore/core/src/pos/state_sync/request_manager.rs diff --git a/core/src/pos/state_sync/shared_components.rs b/crates/cfxcore/core/src/pos/state_sync/shared_components.rs similarity index 99% rename from core/src/pos/state_sync/shared_components.rs rename to crates/cfxcore/core/src/pos/state_sync/shared_components.rs index 0b392ba8b9..e7528767b0 100644 --- a/core/src/pos/state_sync/shared_components.rs +++ b/crates/cfxcore/core/src/pos/state_sync/shared_components.rs @@ -39,8 +39,7 @@ impl SyncState { pub fn new( committed_ledger_info: LedgerInfoWithSignatures, synced_trees: ExecutedTrees, current_epoch_state: EpochState, - ) -> Self - { + ) -> Self { let trusted_epoch_state = committed_ledger_info .ledger_info() .next_epoch_state() diff --git a/core/src/pos/state_sync/tests/integration_tests.rs b/crates/cfxcore/core/src/pos/state_sync/tests/integration_tests.rs similarity index 100% rename from core/src/pos/state_sync/tests/integration_tests.rs rename to crates/cfxcore/core/src/pos/state_sync/tests/integration_tests.rs diff --git a/core/src/pos/state_sync/tests/test_harness.rs b/crates/cfxcore/core/src/pos/state_sync/tests/test_harness.rs similarity index 100% rename from core/src/pos/state_sync/tests/test_harness.rs rename to crates/cfxcore/core/src/pos/state_sync/tests/test_harness.rs diff --git a/core/src/pos/storage/README.md b/crates/cfxcore/core/src/pos/storage/README.md similarity index 100% rename from core/src/pos/storage/README.md rename to crates/cfxcore/core/src/pos/storage/README.md diff --git a/core/src/pos/storage/accumulator/Cargo.toml b/crates/cfxcore/core/src/pos/storage/accumulator/Cargo.toml similarity index 100% rename from core/src/pos/storage/accumulator/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/accumulator/Cargo.toml diff --git a/core/src/pos/storage/accumulator/src/lib.rs b/crates/cfxcore/core/src/pos/storage/accumulator/src/lib.rs similarity index 99% rename from core/src/pos/storage/accumulator/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/accumulator/src/lib.rs index 959f4f6110..af033c3202 100644 --- a/core/src/pos/storage/accumulator/src/lib.rs +++ b/crates/cfxcore/core/src/pos/storage/accumulator/src/lib.rs @@ -193,8 +193,7 @@ where pub fn get_range_proof( reader: &R, full_acc_leaves: LeafCount, first_leaf_index: Option, num_leaves: LeafCount, - ) -> Result> - { + ) -> Result> { MerkleAccumulatorView::::new(reader, full_acc_leaves) .get_range_proof(first_leaf_index, num_leaves) } @@ -204,8 +203,7 @@ where pub fn get_range_proof_positions( reader: &R, full_acc_leaves: LeafCount, first_leaf_index: Option, num_leaves: LeafCount, - ) -> Result<(Vec, Vec)> - { + ) -> Result<(Vec, Vec)> { MerkleAccumulatorView::::new(reader, full_acc_leaves) .get_range_proof_positions(first_leaf_index, num_leaves) } diff --git a/core/src/pos/storage/accumulator/src/test_helpers.rs b/crates/cfxcore/core/src/pos/storage/accumulator/src/test_helpers.rs similarity index 99% rename from core/src/pos/storage/accumulator/src/test_helpers.rs rename to crates/cfxcore/core/src/pos/storage/accumulator/src/test_helpers.rs index 4de83226e8..70b2c024dc 100644 --- a/core/src/pos/storage/accumulator/src/test_helpers.rs +++ b/crates/cfxcore/core/src/pos/storage/accumulator/src/test_helpers.rs @@ -175,8 +175,7 @@ impl MockHashStore { pub(crate) fn verify( store: &MockHashStore, num_leaves: u64, root_hash: HashValue, leaves: &[HashValue], first_leaf_idx: u64, -) -{ +) { leaves.iter().enumerate().for_each(|(i, hash)| { let leaf_index = first_leaf_idx + i as u64; let proof = diff --git a/core/src/pos/storage/accumulator/src/tests/mod.rs b/crates/cfxcore/core/src/pos/storage/accumulator/src/tests/mod.rs similarity index 100% rename from core/src/pos/storage/accumulator/src/tests/mod.rs rename to crates/cfxcore/core/src/pos/storage/accumulator/src/tests/mod.rs diff --git a/core/src/pos/storage/accumulator/src/tests/proof_test.rs b/crates/cfxcore/core/src/pos/storage/accumulator/src/tests/proof_test.rs similarity index 100% rename from core/src/pos/storage/accumulator/src/tests/proof_test.rs rename to crates/cfxcore/core/src/pos/storage/accumulator/src/tests/proof_test.rs diff --git a/core/src/pos/storage/accumulator/src/tests/write_test.rs b/crates/cfxcore/core/src/pos/storage/accumulator/src/tests/write_test.rs similarity index 100% rename from core/src/pos/storage/accumulator/src/tests/write_test.rs rename to crates/cfxcore/core/src/pos/storage/accumulator/src/tests/write_test.rs diff --git a/core/src/pos/storage/backup/backup-cli/Cargo.toml b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/Cargo.toml similarity index 100% rename from core/src/pos/storage/backup/backup-cli/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/Cargo.toml diff --git a/core/src/pos/storage/backup/backup-cli/proptest-regressions/utils/stream/futures_unordered_x.txt b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/proptest-regressions/utils/stream/futures_unordered_x.txt similarity index 100% rename from core/src/pos/storage/backup/backup-cli/proptest-regressions/utils/stream/futures_unordered_x.txt rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/proptest-regressions/utils/stream/futures_unordered_x.txt diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/backup.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/backup.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/backup.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/backup.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/manifest.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/manifest.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/manifest.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/manifest.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/restore.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/restore.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/restore.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/restore.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/tests.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/tests.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/tests.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/epoch_ending/tests.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/backup.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/backup.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/backup.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/backup.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/manifest.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/manifest.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/manifest.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/manifest.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/restore.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/restore.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/restore.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/restore.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/tests.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/tests.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/tests.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/state_snapshot/tests.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/tests.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/tests.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/tests.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/tests.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/backup.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/backup.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/backup.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/backup.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/manifest.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/manifest.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/manifest.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/manifest.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/restore.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/restore.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/restore.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/restore.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/tests.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/tests.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/tests.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/backup_types/transaction/tests.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/bin/db-backup-verify.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/bin/db-backup-verify.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/bin/db-backup-verify.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/bin/db-backup-verify.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/bin/db-backup.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/bin/db-backup.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/bin/db-backup.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/bin/db-backup.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/bin/db-restore.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/bin/db-restore.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/bin/db-restore.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/bin/db-restore.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/coordinators/backup.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/backup.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/coordinators/backup.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/backup.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/coordinators/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/coordinators/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/coordinators/restore.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/restore.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/coordinators/restore.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/restore.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/coordinators/verify.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/verify.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/coordinators/verify.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/coordinators/verify.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/lib.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/lib.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/lib.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metadata/cache.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metadata/cache.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metadata/cache.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metadata/cache.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metadata/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metadata/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metadata/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metadata/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metadata/view.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metadata/view.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metadata/view.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metadata/view.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metrics/backup.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/backup.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metrics/backup.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/backup.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metrics/metadata.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/metadata.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metrics/metadata.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/metadata.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metrics/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metrics/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metrics/restore.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/restore.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metrics/restore.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/restore.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/metrics/verify.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/verify.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/metrics/verify.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/metrics/verify.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/azure.sample.toml b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/azure.sample.toml similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/azure.sample.toml rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/azure.sample.toml diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/command.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/command.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/command.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/command.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/config.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/config.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/config.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/config.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/gcp.sample.toml b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/gcp.sample.toml similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/gcp.sample.toml rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/gcp.sample.toml diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/local_folder.sample.toml b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/local_folder.sample.toml similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/local_folder.sample.toml rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/local_folder.sample.toml diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/s3.sample.toml b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/s3.sample.toml similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/s3.sample.toml rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/s3.sample.toml diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/tests.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/tests.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/tests.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/command_adapter/tests.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/local_fs/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/local_fs/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/local_fs/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/local_fs/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/local_fs/tests.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/local_fs/tests.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/local_fs/tests.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/local_fs/tests.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/test_util.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/test_util.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/test_util.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/test_util.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/storage/tests.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/tests.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/storage/tests.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/storage/tests.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/backup_service_client.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/backup_service_client.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/backup_service_client.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/backup_service_client.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/error_notes.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/error_notes.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/error_notes.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/error_notes.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/read_record_bytes.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/read_record_bytes.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/read_record_bytes.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/read_record_bytes.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/storage_ext.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/storage_ext.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/storage_ext.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/storage_ext.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/stream/buffered_x.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/buffered_x.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/stream/buffered_x.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/buffered_x.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_ordered_x.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_ordered_x.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_ordered_x.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_ordered_x.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_unordered_x.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_unordered_x.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_unordered_x.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/futures_unordered_x.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/stream/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/stream/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/stream/mod.rs diff --git a/core/src/pos/storage/backup/backup-cli/src/utils/test_utils.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/test_utils.rs similarity index 100% rename from core/src/pos/storage/backup/backup-cli/src/utils/test_utils.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-cli/src/utils/test_utils.rs diff --git a/core/src/pos/storage/backup/backup-service/Cargo.toml b/crates/cfxcore/core/src/pos/storage/backup/backup-service/Cargo.toml similarity index 100% rename from core/src/pos/storage/backup/backup-service/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/backup/backup-service/Cargo.toml diff --git a/core/src/pos/storage/backup/backup-service/src/handlers/mod.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-service/src/handlers/mod.rs similarity index 100% rename from core/src/pos/storage/backup/backup-service/src/handlers/mod.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-service/src/handlers/mod.rs diff --git a/core/src/pos/storage/backup/backup-service/src/handlers/utils.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-service/src/handlers/utils.rs similarity index 100% rename from core/src/pos/storage/backup/backup-service/src/handlers/utils.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-service/src/handlers/utils.rs diff --git a/core/src/pos/storage/backup/backup-service/src/lib.rs b/crates/cfxcore/core/src/pos/storage/backup/backup-service/src/lib.rs similarity index 100% rename from core/src/pos/storage/backup/backup-service/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/backup/backup-service/src/lib.rs diff --git a/core/src/pos/storage/cached-pos-ledger-db/Cargo.toml b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/Cargo.toml similarity index 88% rename from core/src/pos/storage/cached-pos-ledger-db/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/Cargo.toml index 09a4e96fc7..26afc16975 100644 --- a/core/src/pos/storage/cached-pos-ledger-db/Cargo.toml +++ b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" anyhow = "1.0.38" serde = { version = "1.0.124", features = ["derive"] } -consensus-types = { path = "../../consensus/consensus-types"} +consensus-types = { path = "../../consensus/consensus-types" } pos-ledger-db = { path = "../pos-ledger-db" } diem-crypto = { path = "../../crypto/crypto" } diem-infallible = { path = "../../common/infallible" } diff --git a/core/src/pos/storage/cached-pos-ledger-db/src/lib.rs b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/lib.rs similarity index 98% rename from core/src/pos/storage/cached-pos-ledger-db/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/lib.rs index 6e2756999d..ddf86313e5 100644 --- a/core/src/pos/storage/cached-pos-ledger-db/src/lib.rs +++ b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/lib.rs @@ -97,8 +97,7 @@ impl CachedPosLedgerDB { initial_nodes: Vec<(NodeID, u64)>, initial_committee: Vec<(AccountAddress, u64)>, genesis_pivot_decision: Option, - ) -> Self - { + ) -> Self { // if initial_nodes.is_empty() { // let access_paths = ON_CHAIN_CONFIG_REGISTRY // .iter() @@ -157,8 +156,7 @@ impl CachedPosLedgerDB { &self, committed_trees: ExecutedTrees, committed_ledger_info: &LedgerInfo, committed_txns: Vec, reconfig_events: Vec, - ) - { + ) { self.cache.lock().update_block_tree_root( committed_trees, committed_ledger_info, @@ -178,8 +176,7 @@ impl CachedPosLedgerDB { Vec, /* block transactions */ ProcessedVMOutput, /* block execution output */ ), - ) -> Result<(), Error> - { + ) -> Result<(), Error> { self.cache.lock().add_block(parent_block_id, block) } @@ -188,8 +185,7 @@ impl CachedPosLedgerDB { pub fn prune( &self, committed_ledger_info: &LedgerInfo, committed_txns: Vec, reconfig_events: Vec, - ) -> Result - { + ) -> Result { self.cache.lock().prune( committed_ledger_info, committed_txns, diff --git a/core/src/pos/storage/cached-pos-ledger-db/src/logging.rs b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/logging.rs similarity index 100% rename from core/src/pos/storage/cached-pos-ledger-db/src/logging.rs rename to crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/logging.rs diff --git a/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/mod.rs b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/mod.rs similarity index 99% rename from core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/mod.rs rename to crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/mod.rs index e1a9d74bdd..dfea6f58bc 100644 --- a/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/mod.rs @@ -62,8 +62,7 @@ impl SpeculationBlock { block_map: Arc< Mutex>>>, >, - ) -> Self - { + ) -> Self { Self { id, transactions, @@ -195,8 +194,7 @@ impl SpeculationCache { &mut self, mut committed_trees: ExecutedTrees, committed_ledger_info: &LedgerInfo, committed_txns: Vec, reconfig_events: Vec, - ) - { + ) { let new_root_block_id = if committed_ledger_info.ends_epoch() { // Update the root block id with reconfig virtual block id, to be // consistent with the logic of Consensus. @@ -242,8 +240,7 @@ impl SpeculationCache { Vec, /* block transactions */ ProcessedVMOutput, /* block execution output */ ), - ) -> Result<(), Error> - { + ) -> Result<(), Error> { // Check existence first let (block_id, txns, output) = block; @@ -292,8 +289,7 @@ impl SpeculationCache { pub fn prune( &mut self, committed_ledger_info: &LedgerInfo, committed_txns: Vec, reconfig_events: Vec, - ) -> Result - { + ) -> Result { let old_committed_root = self.committed_block_id; let arc_latest_committed_block = self.get_block(&committed_ledger_info.consensus_block_id())?; diff --git a/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/test.rs b/crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/test.rs similarity index 100% rename from core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/test.rs rename to crates/cfxcore/core/src/pos/storage/cached-pos-ledger-db/src/speculation_cache/test.rs diff --git a/core/src/pos/storage/data.png b/crates/cfxcore/core/src/pos/storage/data.png similarity index 100% rename from core/src/pos/storage/data.png rename to crates/cfxcore/core/src/pos/storage/data.png diff --git a/core/src/pos/storage/diemdb-benchmark/Cargo.toml b/crates/cfxcore/core/src/pos/storage/diemdb-benchmark/Cargo.toml similarity index 100% rename from core/src/pos/storage/diemdb-benchmark/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/diemdb-benchmark/Cargo.toml diff --git a/core/src/pos/storage/diemdb-benchmark/src/lib.rs b/crates/cfxcore/core/src/pos/storage/diemdb-benchmark/src/lib.rs similarity index 100% rename from core/src/pos/storage/diemdb-benchmark/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/diemdb-benchmark/src/lib.rs diff --git a/core/src/pos/storage/diemdb-benchmark/src/main.rs b/crates/cfxcore/core/src/pos/storage/diemdb-benchmark/src/main.rs similarity index 100% rename from core/src/pos/storage/diemdb-benchmark/src/main.rs rename to crates/cfxcore/core/src/pos/storage/diemdb-benchmark/src/main.rs diff --git a/core/src/pos/storage/diemsum/Cargo.toml b/crates/cfxcore/core/src/pos/storage/diemsum/Cargo.toml similarity index 100% rename from core/src/pos/storage/diemsum/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/diemsum/Cargo.toml diff --git a/core/src/pos/storage/diemsum/src/main.rs b/crates/cfxcore/core/src/pos/storage/diemsum/src/main.rs similarity index 100% rename from core/src/pos/storage/diemsum/src/main.rs rename to crates/cfxcore/core/src/pos/storage/diemsum/src/main.rs diff --git a/core/src/pos/storage/inspector/Cargo.toml b/crates/cfxcore/core/src/pos/storage/inspector/Cargo.toml similarity index 100% rename from core/src/pos/storage/inspector/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/inspector/Cargo.toml diff --git a/core/src/pos/storage/inspector/src/main.rs b/crates/cfxcore/core/src/pos/storage/inspector/src/main.rs similarity index 100% rename from core/src/pos/storage/inspector/src/main.rs rename to crates/cfxcore/core/src/pos/storage/inspector/src/main.rs diff --git a/core/src/pos/storage/jellyfish-merkle/Cargo.toml b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/Cargo.toml similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/Cargo.toml diff --git a/core/src/pos/storage/jellyfish-merkle/proptest-regressions/restore/restore_test.txt b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/proptest-regressions/restore/restore_test.txt similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/proptest-regressions/restore/restore_test.txt rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/proptest-regressions/restore/restore_test.txt diff --git a/core/src/pos/storage/jellyfish-merkle/src/iterator/iterator_test.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/iterator/iterator_test.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/iterator/iterator_test.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/iterator/iterator_test.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/iterator/mod.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/iterator/mod.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/iterator/mod.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/iterator/mod.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/jellyfish_merkle_test.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/jellyfish_merkle_test.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/jellyfish_merkle_test.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/jellyfish_merkle_test.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/lib.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/lib.rs similarity index 99% rename from core/src/pos/storage/jellyfish-merkle/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/lib.rs index b58bb4308c..cfb82b8ffa 100644 --- a/core/src/pos/storage/jellyfish-merkle/src/lib.rs +++ b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/lib.rs @@ -305,8 +305,7 @@ where fn put( key: HashValue, value: V, version: Version, tree_cache: &mut TreeCache, - ) -> Result<()> - { + ) -> Result<()> { let nibble_path = NibblePath::new(key.to_vec()); // Get the root node. If this is the first operation, it would get the @@ -336,8 +335,7 @@ where fn insert_at( node_key: NodeKey, version: Version, nibble_iter: &mut NibbleIterator, value: V, tree_cache: &mut TreeCache, - ) -> Result<(NodeKey, Node)> - { + ) -> Result<(NodeKey, Node)> { let node = tree_cache.get_node(&node_key)?; match node { Node::Internal(internal_node) => Self::insert_at_internal_node( @@ -384,8 +382,7 @@ where mut node_key: NodeKey, internal_node: InternalNode, version: Version, nibble_iter: &mut NibbleIterator, value: V, tree_cache: &mut TreeCache, - ) -> Result<(NodeKey, Node)> - { + ) -> Result<(NodeKey, Node)> { // We always delete the existing internal node here because it will not // be referenced anyway since this version. tree_cache.delete_node(&node_key, false /* is_leaf */); @@ -447,8 +444,7 @@ where mut node_key: NodeKey, existing_leaf_node: LeafNode, version: Version, nibble_iter: &mut NibbleIterator, value: V, tree_cache: &mut TreeCache, - ) -> Result<(NodeKey, Node)> - { + ) -> Result<(NodeKey, Node)> { // We are on a leaf node but trying to insert another node, so we may // diverge. We always delete the existing leaf node here because // it will not be referenced anyway since this version. @@ -574,8 +570,7 @@ where fn create_leaf_node( node_key: NodeKey, nibble_iter: &NibbleIterator, value: V, tree_cache: &mut TreeCache, - ) -> Result<(NodeKey, Node)> - { + ) -> Result<(NodeKey, Node)> { // Get the underlying bytes of nibble_iter which must be a key, i.e., // hashed account address with `HashValue::LENGTH` bytes. let new_leaf_node = Node::new_leaf( diff --git a/core/src/pos/storage/jellyfish-merkle/src/metrics.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/metrics.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/metrics.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/metrics.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/mock_tree_store.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/mock_tree_store.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/mock_tree_store.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/mock_tree_store.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/nibble_path/mod.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/nibble_path/mod.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/nibble_path/mod.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/nibble_path/mod.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/nibble_path/nibble_path_test.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/nibble_path/nibble_path_test.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/nibble_path/nibble_path_test.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/nibble_path/nibble_path_test.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/node_type/mod.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/node_type/mod.rs similarity index 99% rename from core/src/pos/storage/jellyfish-merkle/src/node_type/mod.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/node_type/mod.rs index 09cca5f5e0..26e2b0194b 100644 --- a/core/src/pos/storage/jellyfish-merkle/src/node_type/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/node_type/mod.rs @@ -381,8 +381,7 @@ impl InternalNode { fn merkle_hash( &self, start: u8, width: u8, (existence_bitmap, leaf_bitmap): (u16, u16), - ) -> HashValue - { + ) -> HashValue { // Given a bit [start, 1 << nibble_height], return the value of that // range. let (range_existence_bitmap, range_leaf_bitmap) = diff --git a/core/src/pos/storage/jellyfish-merkle/src/node_type/node_type_test.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/node_type/node_type_test.rs similarity index 99% rename from core/src/pos/storage/jellyfish-merkle/src/node_type/node_type_test.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/node_type/node_type_test.rs index 4f1127fb8d..66ab5d87c2 100644 --- a/core/src/pos/storage/jellyfish-merkle/src/node_type/node_type_test.rs +++ b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/node_type/node_type_test.rs @@ -727,8 +727,7 @@ impl BinaryTreeNode { fn new_internal( first_child_index: u8, num_children: u8, left: BinaryTreeNode, right: BinaryTreeNode, - ) -> Self - { + ) -> Self { let hash = SparseMerkleInternalNode::new(left.hash(), right.hash()).hash(); diff --git a/core/src/pos/storage/jellyfish-merkle/src/restore/mod.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/restore/mod.rs similarity index 99% rename from core/src/pos/storage/jellyfish-merkle/src/restore/mod.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/restore/mod.rs index a963f8303e..88da0fd052 100644 --- a/core/src/pos/storage/jellyfish-merkle/src/restore/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/restore/mod.rs @@ -236,8 +236,7 @@ where V: crate::Value fn recover_partial_nodes( store: &dyn TreeReader, version: Version, rightmost_leaf_node_key: NodeKey, - ) -> Result>> - { + ) -> Result>> { ensure!( rightmost_leaf_node_key.nibble_path().num_nibbles() > 0, "Root node would not be written until entire restoration process has completed \ @@ -404,8 +403,7 @@ where V: crate::Value &mut self, child_index: usize, existing_leaf: LeafNode, new_key: HashValue, new_value: V, mut remaining_nibbles: NibbleIterator<'_>, - ) - { + ) { let num_existing_partial_nodes = self.partial_nodes.len(); // The node at this position becomes an internal node. Since we may diff --git a/core/src/pos/storage/jellyfish-merkle/src/restore/restore_test.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/restore/restore_test.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/restore/restore_test.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/restore/restore_test.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/test_helper.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/test_helper.rs similarity index 99% rename from core/src/pos/storage/jellyfish-merkle/src/test_helper.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/test_helper.rs index 2b4ff2dd00..2fcceda181 100644 --- a/core/src/pos/storage/jellyfish-merkle/src/test_helper.rs +++ b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/test_helper.rs @@ -172,8 +172,7 @@ pub fn test_get_range_proof( fn test_existent_keys_impl<'a, V: crate::TestValue>( tree: &JellyfishMerkleTree<'a, MockTreeStore, V>, version: Version, existent_kvs: &HashMap, -) -{ +) { let root_hash = tree.get_root_hash(version).unwrap(); for (key, value) in existent_kvs { @@ -186,8 +185,7 @@ fn test_existent_keys_impl<'a, V: crate::TestValue>( fn test_nonexistent_keys_impl<'a, V: crate::TestValue>( tree: &JellyfishMerkleTree<'a, MockTreeStore, V>, version: Version, nonexistent_keys: &[HashValue], -) -{ +) { let root_hash = tree.get_root_hash(version).unwrap(); for key in nonexistent_keys { @@ -202,8 +200,7 @@ fn test_nonexistent_keys_impl<'a, V: crate::TestValue>( fn verify_range_proof( expected_root_hash: HashValue, btree: BTreeMap, proof: SparseMerkleRangeProof, -) -{ +) { // For example, given the following sparse Merkle tree: // // root diff --git a/core/src/pos/storage/jellyfish-merkle/src/tree_cache/mod.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/tree_cache/mod.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/tree_cache/mod.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/tree_cache/mod.rs diff --git a/core/src/pos/storage/jellyfish-merkle/src/tree_cache/tree_cache_test.rs b/crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/tree_cache/tree_cache_test.rs similarity index 100% rename from core/src/pos/storage/jellyfish-merkle/src/tree_cache/tree_cache_test.rs rename to crates/cfxcore/core/src/pos/storage/jellyfish-merkle/src/tree_cache/tree_cache_test.rs diff --git a/core/src/pos/storage/pos-ledger-db/Cargo.toml b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/Cargo.toml similarity index 91% rename from core/src/pos/storage/pos-ledger-db/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/Cargo.toml index 919bccc91f..710da33d32 100644 --- a/core/src/pos/storage/pos-ledger-db/Cargo.toml +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/Cargo.toml @@ -36,8 +36,8 @@ diem-types = { path = "../../types" } num-variants = { path = "../../common/num-variants" } schemadb = { path = "../schemadb" } storage-interface = { path = "../storage-interface" } -consensus-types = {path = "../../consensus/consensus-types"} -executor-types = {path = "../../types/executor-types"} +consensus-types = {path = "../../consensus/consensus-types" } +executor-types = {path = "../../types/executor-types" } [dev-dependencies] proptest = "1.0.0" @@ -48,7 +48,7 @@ diem-jellyfish-merkle = { path = "../jellyfish-merkle", features = ["fuzzing"] } diem-proptest-helpers = { path = "../../common/proptest-helpers" } diem-temppath = { path = "../../common/temppath" } diem-types = { path = "../../types", features = ["fuzzing"] } -move-core-types = { path = "../../types/move-core-types"} +move-core-types = { path = "../../types/move-core-types" } [features] default = [] diff --git a/core/src/pos/storage/pos-ledger-db/proptest-regressions/diemdb_test.txt b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/proptest-regressions/diemdb_test.txt similarity index 100% rename from core/src/pos/storage/pos-ledger-db/proptest-regressions/diemdb_test.txt rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/proptest-regressions/diemdb_test.txt diff --git a/core/src/pos/storage/pos-ledger-db/proptest-regressions/ledger_store/ledger_info_test.txt b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/proptest-regressions/ledger_store/ledger_info_test.txt similarity index 100% rename from core/src/pos/storage/pos-ledger-db/proptest-regressions/ledger_store/ledger_info_test.txt rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/proptest-regressions/ledger_store/ledger_info_test.txt diff --git a/core/src/pos/storage/pos-ledger-db/src/backup/backup_handler.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/backup_handler.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/backup/backup_handler.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/backup_handler.rs index 28732cee03..21186dd0a5 100644 --- a/core/src/pos/storage/pos-ledger-db/src/backup/backup_handler.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/backup_handler.rs @@ -46,8 +46,7 @@ impl BackupHandler { ledger_store: Arc, transaction_store: Arc, state_store: Arc, event_store: Arc, - ) -> Self - { + ) -> Self { Self { ledger_store, transaction_store, diff --git a/core/src/pos/storage/pos-ledger-db/src/backup/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/backup/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/backup/restore_handler.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/restore_handler.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/backup/restore_handler.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/restore_handler.rs index eb80a19e7d..2d20a5761b 100644 --- a/core/src/pos/storage/pos-ledger-db/src/backup/restore_handler.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/restore_handler.rs @@ -40,8 +40,7 @@ impl RestoreHandler { db: Arc, diemdb: Arc, ledger_store: Arc, transaction_store: Arc, state_store: Arc, event_store: Arc, - ) -> Self - { + ) -> Self { Self { db, diemdb, @@ -125,8 +124,7 @@ impl RestoreHandler { pub fn save_transactions( &self, first_version: Version, txns: &[Transaction], txn_infos: &[TransactionInfo], events: &[Vec], - ) -> Result<()> - { + ) -> Result<()> { let mut cs = ChangeSet::new(); for (idx, txn) in txns.iter().enumerate() { self.transaction_store.put_transaction( diff --git a/core/src/pos/storage/pos-ledger-db/src/backup/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/backup/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/backup/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/change_set.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/change_set.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/change_set.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/change_set.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/diemdb_test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/diemdb_test.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/diemdb_test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/diemdb_test.rs index 54833e8ca2..dbe7081dc7 100644 --- a/core/src/pos/storage/pos-ledger-db/src/diemdb_test.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/diemdb_test.rs @@ -346,8 +346,7 @@ fn verify_committed_transactions( _db: &PosLedgerDB, _txns_to_commit: &[TransactionToCommit], _first_version: Version, _ledger_info_with_sigs: &LedgerInfoWithSignatures, _is_latest: bool, -) -{ +) { // TODO(lpl): Verify this. return; } diff --git a/core/src/pos/storage/pos-ledger-db/src/diemsum/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/diemsum/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/diemsum/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/diemsum/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/errors.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/errors.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/errors.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/errors.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/event_store/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/event_store/mod.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/event_store/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/event_store/mod.rs index 3a0e5ce208..6b30caf157 100644 --- a/core/src/pos/storage/pos-ledger-db/src/event_store/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/event_store/mod.rs @@ -225,8 +225,7 @@ impl EventStore { pub(crate) fn put_events_multiple_versions( &self, first_version: u64, event_vecs: &[Vec], cs: &mut ChangeSet, - ) -> Result> - { + ) -> Result> { event_vecs .iter() .enumerate() diff --git a/core/src/pos/storage/pos-ledger-db/src/event_store/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/event_store/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/event_store/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/event_store/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/ledger_counters/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_counters/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/ledger_counters/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_counters/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/ledger_counters/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_counters/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/ledger_counters/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_counters/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/ledger_store/ledger_info_test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/ledger_info_test.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/ledger_store/ledger_info_test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/ledger_info_test.rs index 769c6ecbd2..2befc27232 100644 --- a/core/src/pos/storage/pos-ledger-db/src/ledger_store/ledger_info_test.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/ledger_info_test.rs @@ -187,8 +187,7 @@ proptest! { fn set_up( path: &impl AsRef, ledger_infos_with_sigs: &[LedgerInfoWithSignatures], -) -> PosLedgerDB -{ +) -> PosLedgerDB { let db = PosLedgerDB::new_for_test(path); let store = &db.ledger_store; diff --git a/core/src/pos/storage/pos-ledger-db/src/ledger_store/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/mod.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/ledger_store/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/mod.rs index 1cb7f742ad..cbde0b0292 100644 --- a/core/src/pos/storage/pos-ledger-db/src/ledger_store/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/mod.rs @@ -382,8 +382,7 @@ impl LedgerStore { pub fn get_transaction_range_proof( &self, start_version: Option, num_txns: u64, ledger_version: Version, - ) -> Result - { + ) -> Result { Accumulator::get_range_proof( self, ledger_version + 1, /* num_leaves */ @@ -409,8 +408,7 @@ impl LedgerStore { pub fn put_transaction_infos( &self, first_version: u64, txn_infos: &[TransactionInfo], cs: &mut ChangeSet, - ) -> Result - { + ) -> Result { // write txn_info (first_version..first_version + txn_infos.len() as u64) .zip_eq(txn_infos.iter()) @@ -436,8 +434,7 @@ impl LedgerStore { pub fn put_ledger_info( &self, ledger_info_with_sigs: &LedgerInfoWithSignatures, cs: &mut ChangeSet, - ) -> Result<()> - { + ) -> Result<()> { let ledger_info = ledger_info_with_sigs.ledger_info(); diem_debug!("put_ledger_info: {:?}", ledger_info); @@ -553,8 +550,7 @@ impl LedgerStore { pub fn put_ledger_info_by_voted_block( &self, voted_block_id: &HashValue, ledger_info: &LedgerInfoWithSignatures, cs: &mut ChangeSet, - ) -> Result<()> - { + ) -> Result<()> { cs.batch .put::(voted_block_id, ledger_info)?; Ok(()) diff --git a/core/src/pos/storage/pos-ledger-db/src/ledger_store/transaction_info_test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/transaction_info_test.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/ledger_store/transaction_info_test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/transaction_info_test.rs index c7b54bfa36..40a7d72093 100644 --- a/core/src/pos/storage/pos-ledger-db/src/ledger_store/transaction_info_test.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/ledger_store/transaction_info_test.rs @@ -13,8 +13,7 @@ use proptest::{collection::vec, prelude::*}; fn verify( store: &LedgerStore, txn_infos: &[TransactionInfo], first_version: Version, ledger_version: Version, root_hash: HashValue, -) -{ +) { txn_infos .iter() .enumerate() diff --git a/core/src/pos/storage/pos-ledger-db/src/lib.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/lib.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/lib.rs index b62c78133a..6dd2433eb3 100644 --- a/core/src/pos/storage/pos-ledger-db/src/lib.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/lib.rs @@ -283,8 +283,7 @@ impl PosLedgerDB { pub fn open + Clone>( db_root_path: P, readonly: bool, prune_window: Option, rocksdb_config: RocksdbConfig, - ) -> Result - { + ) -> Result { ensure!( prune_window.is_none() || !readonly, "Do not set prune_window when opening readonly.", @@ -471,8 +470,7 @@ impl PosLedgerDB { fn save_transactions_impl( &self, txns_to_commit: &[TransactionToCommit], first_version: u64, mut cs: &mut ChangeSet, - ) -> Result - { + ) -> Result { let last_version = first_version + txns_to_commit.len() as u64 - 1; // Account state updates. Gather account state root hashes @@ -589,8 +587,7 @@ impl DbReader for PosLedgerDB { fn get_transactions( &self, start_version: Version, limit: u64, ledger_version: Version, fetch_events: bool, - ) -> Result - { + ) -> Result { gauged_api("get_transactions", || { error_if_too_many_requested(limit, MAX_LIMIT)?; @@ -681,8 +678,7 @@ impl DbReader for PosLedgerDB { fn get_txn_by_account( &self, address: AccountAddress, seq_num: u64, ledger_version: Version, fetch_events: bool, - ) -> Result> - { + ) -> Result> { gauged_api("get_txn_by_account", || { self.transaction_store .lookup_transaction_by_account( @@ -704,8 +700,7 @@ impl DbReader for PosLedgerDB { fn get_state_proof_with_ledger_info( &self, known_version: u64, ledger_info_with_sigs: LedgerInfoWithSignatures, - ) -> Result<(EpochChangeProof, AccumulatorConsistencyProof)> - { + ) -> Result<(EpochChangeProof, AccumulatorConsistencyProof)> { gauged_api("get_state_proof_with_ledger_info", || { let ledger_info = ledger_info_with_sigs.ledger_info(); ensure!( @@ -763,8 +758,7 @@ impl DbReader for PosLedgerDB { fn get_account_state_with_proof( &self, address: AccountAddress, version: Version, ledger_version: Version, - ) -> Result - { + ) -> Result { gauged_api("get_account_state_with_proof", || { ensure!( version <= ledger_version, @@ -895,8 +889,7 @@ impl DbWriter for PosLedgerDB { HashValue, LedgerInfoWithSignatures, )>, - ) -> Result<()> - { + ) -> Result<()> { gauged_api("save_transactions", || { let num_txns = txns_to_commit.len() as u64; // ledger_info_with_sigs could be None if we are doing state diff --git a/core/src/pos/storage/pos-ledger-db/src/metrics.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/metrics.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/metrics.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/metrics.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/pruner/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/pruner/mod.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/pruner/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/pruner/mod.rs index e3eb96b398..f063ceac9c 100644 --- a/core/src/pos/storage/pos-ledger-db/src/pruner/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/pruner/mod.rs @@ -168,8 +168,7 @@ impl Worker { fn new( db: Arc, command_receiver: Receiver, least_readable_version: Arc, - ) -> Self - { + ) -> Self { Self { db, command_receiver, @@ -361,8 +360,7 @@ impl<'a> StaleNodeIndicesByVersionIterator<'a> { fn new( db: &'a DB, least_readable_version: Version, target_least_readable_version: Version, - ) -> Result - { + ) -> Result { let mut iter = db.iter::(ReadOptions::default())?; iter.seek(&least_readable_version)?; @@ -413,8 +411,7 @@ impl<'a> Iterator for StaleNodeIndicesByVersionIterator<'a> { pub fn prune_state( db: Arc, least_readable_version: Version, target_least_readable_version: Version, max_versions: usize, -) -> Result -{ +) -> Result { let indices = StaleNodeIndicesByVersionIterator::new( &db, least_readable_version, diff --git a/core/src/pos/storage/pos-ledger-db/src/pruner/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/pruner/test.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/pruner/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/pruner/test.rs index 6b303891d3..419a9a368a 100644 --- a/core/src/pos/storage/pos-ledger-db/src/pruner/test.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/pruner/test.rs @@ -18,8 +18,7 @@ fn put_account_state_set( db: &DB, state_store: &StateStore, account_state_set: Vec<(AccountAddress, AccountStateBlob)>, version: Version, -) -> HashValue -{ +) -> HashValue { let mut cs = ChangeSet::new(); let root = state_store .put_account_state_sets( @@ -36,8 +35,7 @@ fn put_account_state_set( fn verify_state_in_store( state_store: &StateStore, address: AccountAddress, expected_value: Option<&AccountStateBlob>, version: Version, -) -{ +) { let (value, _proof) = state_store .get_account_state_with_proof_by_version(address, version) .unwrap(); diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/block_by_epoch_and_round/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/block_by_epoch_and_round/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/block_by_epoch_and_round/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/block_by_epoch_and_round/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/committed_block/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/committed_block/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/committed_block/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/committed_block/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/committed_block_by_view/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/committed_block_by_view/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/committed_block_by_view/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/committed_block_by_view/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/epoch_by_version/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_accumulator/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_key/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/event_by_version/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/jellyfish_merkle_node/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_counters/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_block/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_voted_block/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_voted_block/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_voted_block/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/ledger_info_by_voted_block/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/pos_state/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/pos_state/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/pos_state/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/pos_state/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/pos_state/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/pos_state/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/pos_state/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/pos_state/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/reward_event/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/reward_event/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/reward_event/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/reward_event/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/stale_node_index/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_accumulator/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_by_account/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/mod.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/mod.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/test.rs similarity index 100% rename from core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/schema/transaction_info/test.rs diff --git a/core/src/pos/storage/pos-ledger-db/src/state_store/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/state_store/mod.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/state_store/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/state_store/mod.rs index 8e7a1de53b..139ca741dc 100644 --- a/core/src/pos/storage/pos-ledger-db/src/state_store/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/state_store/mod.rs @@ -70,8 +70,7 @@ impl StateStore { &self, account_state_sets: Vec>, first_version: Version, cs: &mut ChangeSet, - ) -> Result> - { + ) -> Result> { let blob_sets = account_state_sets .into_iter() .map(|account_states| { diff --git a/core/src/pos/storage/pos-ledger-db/src/state_store/state_store_test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/state_store/state_store_test.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/state_store/state_store_test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/state_store/state_store_test.rs index f8eb3fdedd..c5eb40cbc3 100644 --- a/core/src/pos/storage/pos-ledger-db/src/state_store/state_store_test.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/state_store/state_store_test.rs @@ -20,8 +20,7 @@ fn put_account_state_set( account_state_set: Vec<(AccountAddress, AccountStateBlob)>, version: Version, expected_new_nodes: usize, expected_stale_nodes: usize, expected_stale_leaves: usize, -) -> HashValue -{ +) -> HashValue { let mut cs = ChangeSet::new(); let expected_new_leaves = account_state_set.len(); let root = store @@ -53,8 +52,7 @@ fn put_account_state_set( fn prune_stale_indices( store: &StateStore, least_readable_version: Version, target_least_readable_version: Version, limit: usize, -) -{ +) { pruner::prune_state( Arc::clone(&store.db), least_readable_version, @@ -68,8 +66,7 @@ fn verify_state_in_store( store: &StateStore, address: AccountAddress, expected_value: Option<&AccountStateBlob>, version: Version, root: HashValue, -) -{ +) { let (value, proof) = store .get_account_state_with_proof_by_version(address, version) .unwrap(); @@ -367,8 +364,7 @@ proptest! { fn init_store( store: &StateStore, input: impl Iterator, -) -{ +) { for (i, (key, value)) in input.enumerate() { let mut cs = ChangeSet::new(); let account_state_set: HashMap<_, _> = diff --git a/core/src/pos/storage/pos-ledger-db/src/system_store/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/system_store/mod.rs similarity index 98% rename from core/src/pos/storage/pos-ledger-db/src/system_store/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/system_store/mod.rs index 0730a5658a..3003b08b40 100644 --- a/core/src/pos/storage/pos-ledger-db/src/system_store/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/system_store/mod.rs @@ -34,8 +34,7 @@ impl SystemStore { pub fn bump_ledger_counters( &self, first_version: Version, last_version: Version, cs: &mut ChangeSet, - ) -> Result - { + ) -> Result { assert!(first_version <= last_version); let mut counters = if first_version > 0 { diff --git a/core/src/pos/storage/pos-ledger-db/src/system_store/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/system_store/test.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/system_store/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/system_store/test.rs index c5ba3e8b05..89b95e2e89 100644 --- a/core/src/pos/storage/pos-ledger-db/src/system_store/test.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/system_store/test.rs @@ -17,8 +17,7 @@ use std::collections::HashMap; fn bump_ledger_counters( store: &SystemStore, first_version: Version, last_version: Version, counter_bumps: HashMap, -) -> LedgerCounters -{ +) -> LedgerCounters { let mut cs = ChangeSet::new_with_bumps(counter_bumps); let counters = store .bump_ledger_counters(first_version, last_version, &mut cs) diff --git a/core/src/pos/storage/pos-ledger-db/src/test_helper.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/test_helper.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/test_helper.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/test_helper.rs index 1cf69d3737..57f46c1d3f 100644 --- a/core/src/pos/storage/pos-ledger-db/src/test_helper.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/test_helper.rs @@ -26,8 +26,7 @@ fn to_blocks_to_commit( LedgerInfo, Vec, )>, -) -> Result, LedgerInfoWithSignatures)>> -{ +) -> Result, LedgerInfoWithSignatures)>> { // Use temporary DiemDB and STORE LEVEL APIs to calculate hashes on a per // transaction basis. Result is used to test the batch PUBLIC API for // saving everything, i.e. `save_transactions()` diff --git a/core/src/pos/storage/pos-ledger-db/src/transaction_store/mod.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/transaction_store/mod.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/transaction_store/mod.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/transaction_store/mod.rs index 4841eef3c6..b45462fd6c 100644 --- a/core/src/pos/storage/pos-ledger-db/src/transaction_store/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/transaction_store/mod.rs @@ -38,8 +38,7 @@ impl TransactionStore { pub fn lookup_transaction_by_account( &self, address: AccountAddress, sequence_number: u64, ledger_version: Version, - ) -> Result> - { + ) -> Result> { if let Some(version) = self .db .get::(&(address, sequence_number))? diff --git a/core/src/pos/storage/pos-ledger-db/src/transaction_store/test.rs b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/transaction_store/test.rs similarity index 99% rename from core/src/pos/storage/pos-ledger-db/src/transaction_store/test.rs rename to crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/transaction_store/test.rs index 55c70c7cf3..069f8a37ec 100644 --- a/core/src/pos/storage/pos-ledger-db/src/transaction_store/test.rs +++ b/crates/cfxcore/core/src/pos/storage/pos-ledger-db/src/transaction_store/test.rs @@ -160,8 +160,7 @@ fn init_store( mut universe: AccountInfoUniverse, gens: Vec<(Index, SignatureCheckedTransactionGen)>, store: &TransactionStore, -) -> Vec -{ +) -> Vec { let txns = gens .into_iter() .map(|(index, gen)| { diff --git a/core/src/pos/storage/schemadb/Cargo.toml b/crates/cfxcore/core/src/pos/storage/schemadb/Cargo.toml similarity index 100% rename from core/src/pos/storage/schemadb/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/schemadb/Cargo.toml diff --git a/core/src/pos/storage/schemadb/src/lib.rs b/crates/cfxcore/core/src/pos/storage/schemadb/src/lib.rs similarity index 99% rename from core/src/pos/storage/schemadb/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/schemadb/src/lib.rs index 280bd964c5..ea32789031 100644 --- a/core/src/pos/storage/schemadb/src/lib.rs +++ b/crates/cfxcore/core/src/pos/storage/schemadb/src/lib.rs @@ -212,8 +212,7 @@ impl DB { pub fn open( path: impl AsRef, name: &'static str, column_families: Vec, db_opts: Options, - ) -> Result - { + ) -> Result { { let cfs_set: HashSet<_> = column_families.iter().collect(); ensure!( @@ -236,16 +235,14 @@ impl DB { pub fn open_readonly( path: impl AsRef, name: &'static str, column_families: Vec, db_opts: Options, - ) -> Result - { + ) -> Result { DB::open_cf_readonly(db_opts, path, name, column_families) } fn open_cf( db_opts: Options, path: impl AsRef, name: &'static str, column_families: Vec, - ) -> Result - { + ) -> Result { let inner = rocksdb::DB::open_cf( db_opts, path.as_ref().to_str().ok_or_else(|| { @@ -271,8 +268,7 @@ impl DB { fn open_cf_readonly( opts: Options, path: impl AsRef, name: &'static str, column_families: Vec, - ) -> Result - { + ) -> Result { let error_if_log_file_exists = false; let inner = rocksdb::DB::open_cf_for_read_only( opts, diff --git a/core/src/pos/storage/schemadb/src/metrics.rs b/crates/cfxcore/core/src/pos/storage/schemadb/src/metrics.rs similarity index 100% rename from core/src/pos/storage/schemadb/src/metrics.rs rename to crates/cfxcore/core/src/pos/storage/schemadb/src/metrics.rs diff --git a/core/src/pos/storage/schemadb/src/schema.rs b/crates/cfxcore/core/src/pos/storage/schemadb/src/schema.rs similarity index 100% rename from core/src/pos/storage/schemadb/src/schema.rs rename to crates/cfxcore/core/src/pos/storage/schemadb/src/schema.rs diff --git a/core/src/pos/storage/schemadb/tests/db.rs b/crates/cfxcore/core/src/pos/storage/schemadb/tests/db.rs similarity index 100% rename from core/src/pos/storage/schemadb/tests/db.rs rename to crates/cfxcore/core/src/pos/storage/schemadb/tests/db.rs diff --git a/core/src/pos/storage/schemadb/tests/iterator.rs b/crates/cfxcore/core/src/pos/storage/schemadb/tests/iterator.rs similarity index 100% rename from core/src/pos/storage/schemadb/tests/iterator.rs rename to crates/cfxcore/core/src/pos/storage/schemadb/tests/iterator.rs diff --git a/core/src/pos/storage/scratchpad/Cargo.toml b/crates/cfxcore/core/src/pos/storage/scratchpad/Cargo.toml similarity index 100% rename from core/src/pos/storage/scratchpad/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/scratchpad/Cargo.toml diff --git a/core/src/pos/storage/scratchpad/src/lib.rs b/crates/cfxcore/core/src/pos/storage/scratchpad/src/lib.rs similarity index 100% rename from core/src/pos/storage/scratchpad/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/scratchpad/src/lib.rs diff --git a/core/src/pos/storage/scratchpad/src/sparse_merkle/mod.rs b/crates/cfxcore/core/src/pos/storage/scratchpad/src/sparse_merkle/mod.rs similarity index 99% rename from core/src/pos/storage/scratchpad/src/sparse_merkle/mod.rs rename to crates/cfxcore/core/src/pos/storage/scratchpad/src/sparse_merkle/mod.rs index fd37772684..a4d83af928 100644 --- a/core/src/pos/storage/scratchpad/src/sparse_merkle/mod.rs +++ b/crates/cfxcore/core/src/pos/storage/scratchpad/src/sparse_merkle/mod.rs @@ -215,8 +215,7 @@ where V: Clone + CryptoHash pub fn batch_update( &self, update_batch: Vec>, proof_reader: &impl ProofRead, - ) -> Result<(Vec, Self), UpdateError> - { + ) -> Result<(Vec, Self), UpdateError> { let mut current_state_tree = self.clone(); let mut result_hashes = Vec::with_capacity(update_batch.len()); @@ -301,8 +300,7 @@ where V: Clone + CryptoHash fn construct_subtree_at_bottom( current_subtree: &SubTree, key: HashValue, new_value: V, remaining_bits: HashValueBitIterator, proof_reader: &impl ProofRead, - ) -> Result, UpdateError> - { + ) -> Result, UpdateError> { match current_subtree { SubTree::Empty => { // When we reach an empty node, we just place the leaf node at @@ -433,8 +431,7 @@ where V: Clone + CryptoHash key: HashValue, new_value: V, existing_leaf: SubTree, existing_leaf_key: HashValue, distance_from_root_to_existing_leaf: usize, - ) -> SubTree - { + ) -> SubTree { let new_leaf = SubTree::new_leaf_with_value(key, new_value); if key == existing_leaf_key { // This implies that `key` already existed and the proof is an @@ -484,8 +481,7 @@ where V: Clone + CryptoHash fn construct_subtree( bits: impl Iterator, siblings: impl Iterator>, leaf: SubTree, - ) -> SubTree - { + ) -> SubTree { itertools::zip_eq(bits, siblings).fold( leaf, |previous_node, (bit, sibling)| { diff --git a/core/src/pos/storage/scratchpad/src/sparse_merkle/node.rs b/crates/cfxcore/core/src/pos/storage/scratchpad/src/sparse_merkle/node.rs similarity index 100% rename from core/src/pos/storage/scratchpad/src/sparse_merkle/node.rs rename to crates/cfxcore/core/src/pos/storage/scratchpad/src/sparse_merkle/node.rs diff --git a/core/src/pos/storage/scratchpad/src/sparse_merkle/sparse_merkle_test.rs b/crates/cfxcore/core/src/pos/storage/scratchpad/src/sparse_merkle/sparse_merkle_test.rs similarity index 100% rename from core/src/pos/storage/scratchpad/src/sparse_merkle/sparse_merkle_test.rs rename to crates/cfxcore/core/src/pos/storage/scratchpad/src/sparse_merkle/sparse_merkle_test.rs diff --git a/core/src/pos/storage/state-view/Cargo.toml b/crates/cfxcore/core/src/pos/storage/state-view/Cargo.toml similarity index 100% rename from core/src/pos/storage/state-view/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/state-view/Cargo.toml diff --git a/core/src/pos/storage/state-view/src/lib.rs b/crates/cfxcore/core/src/pos/storage/state-view/src/lib.rs similarity index 100% rename from core/src/pos/storage/state-view/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/state-view/src/lib.rs diff --git a/core/src/pos/storage/storage-client/Cargo.toml b/crates/cfxcore/core/src/pos/storage/storage-client/Cargo.toml similarity index 100% rename from core/src/pos/storage/storage-client/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/storage-client/Cargo.toml diff --git a/core/src/pos/storage/storage-client/src/lib.rs b/crates/cfxcore/core/src/pos/storage/storage-client/src/lib.rs similarity index 100% rename from core/src/pos/storage/storage-client/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/storage-client/src/lib.rs diff --git a/core/src/pos/storage/storage-interface/Cargo.toml b/crates/cfxcore/core/src/pos/storage/storage-interface/Cargo.toml similarity index 92% rename from core/src/pos/storage/storage-interface/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/storage-interface/Cargo.toml index 1613d45fed..f64f438b47 100644 --- a/core/src/pos/storage/storage-interface/Cargo.toml +++ b/crates/cfxcore/core/src/pos/storage/storage-interface/Cargo.toml @@ -22,7 +22,7 @@ diem-secure-net = { path = "../../secure/net" } diem-state-view = { path = "../state-view" } diem-types = { path = "../../types" } scratchpad = { path = "../scratchpad" } -move-core-types = { path = "../../types/move-core-types"} +move-core-types = { path = "../../types/move-core-types" } [features] default = [] diff --git a/core/src/pos/storage/storage-interface/src/lib.rs b/crates/cfxcore/core/src/pos/storage/storage-interface/src/lib.rs similarity index 99% rename from core/src/pos/storage/storage-interface/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/storage-interface/src/lib.rs index bdb533db92..5ead9c40e0 100644 --- a/core/src/pos/storage/storage-interface/src/lib.rs +++ b/crates/cfxcore/core/src/pos/storage/storage-interface/src/lib.rs @@ -64,8 +64,7 @@ impl StartupInfo { latest_epoch_state: Option, committed_tree_state: TreeState, synced_tree_state: Option, committed_pos_state: PosState, - ) -> Self - { + ) -> Self { Self { latest_ledger_info, latest_epoch_state, @@ -123,8 +122,7 @@ impl TreeState { num_transactions: LeafCount, ledger_frozen_subtree_hashes: Vec, account_state_root_hash: HashValue, - ) -> Self - { + ) -> Self { Self { num_transactions, ledger_frozen_subtree_hashes, @@ -505,8 +503,7 @@ impl SaveTransactionsRequest { pub fn new( txns_to_commit: Vec, first_version: Version, ledger_info_with_signatures: Option, - ) -> Self - { + ) -> Self { SaveTransactionsRequest { txns_to_commit, first_version, diff --git a/core/src/pos/storage/storage-interface/src/mock.rs b/crates/cfxcore/core/src/pos/storage/storage-interface/src/mock.rs similarity index 96% rename from core/src/pos/storage/storage-interface/src/mock.rs rename to crates/cfxcore/core/src/pos/storage/storage-interface/src/mock.rs index b68f754f7a..5a84189548 100644 --- a/core/src/pos/storage/storage-interface/src/mock.rs +++ b/crates/cfxcore/core/src/pos/storage/storage-interface/src/mock.rs @@ -35,8 +35,7 @@ impl DbReader for MockDbReader { fn get_transactions( &self, _start_version: Version, _batch_size: u64, _ledger_version: Version, _fetch_events: bool, - ) -> Result - { + ) -> Result { unimplemented!() } @@ -64,8 +63,7 @@ impl DbReader for MockDbReader { fn get_txn_by_account( &self, _address: AccountAddress, _seq_num: u64, _ledger_version: Version, _fetch_events: bool, - ) -> Result> - { + ) -> Result> { unimplemented!() } @@ -88,8 +86,7 @@ impl DbReader for MockDbReader { fn get_account_state_with_proof( &self, _address: AccountAddress, _version: Version, _ledger_version: Version, - ) -> Result - { + ) -> Result { unimplemented!() } diff --git a/core/src/pos/storage/storage-interface/src/state_view.rs b/crates/cfxcore/core/src/pos/storage/storage-interface/src/state_view.rs similarity index 99% rename from core/src/pos/storage/storage-interface/src/state_view.rs rename to crates/cfxcore/core/src/pos/storage/storage-interface/src/state_view.rs index 7ffd8bc546..430f51eaa7 100644 --- a/core/src/pos/storage/storage-interface/src/state_view.rs +++ b/crates/cfxcore/core/src/pos/storage/storage-interface/src/state_view.rs @@ -103,8 +103,7 @@ impl<'a> VerifiedStateView<'a> { latest_persistent_state_root: HashValue, speculative_state: &'a SparseMerkleTree, pos_state: PosState, - ) -> Self - { + ) -> Self { // Hack: When there's no transaction in the db but state tree root hash // is not the placeholder hash, it implies that there's // pre-genesis state present. diff --git a/core/src/pos/storage/storage-service/Cargo.toml b/crates/cfxcore/core/src/pos/storage/storage-service/Cargo.toml similarity index 100% rename from core/src/pos/storage/storage-service/Cargo.toml rename to crates/cfxcore/core/src/pos/storage/storage-service/Cargo.toml diff --git a/core/src/pos/storage/storage-service/proptest-regressions/storage_service_test.txt b/crates/cfxcore/core/src/pos/storage/storage-service/proptest-regressions/storage_service_test.txt similarity index 100% rename from core/src/pos/storage/storage-service/proptest-regressions/storage_service_test.txt rename to crates/cfxcore/core/src/pos/storage/storage-service/proptest-regressions/storage_service_test.txt diff --git a/core/src/pos/storage/storage-service/src/lib.rs b/crates/cfxcore/core/src/pos/storage/storage-service/src/lib.rs similarity index 100% rename from core/src/pos/storage/storage-service/src/lib.rs rename to crates/cfxcore/core/src/pos/storage/storage-service/src/lib.rs diff --git a/core/src/pos/storage/storage-service/src/storage_service_test.rs b/crates/cfxcore/core/src/pos/storage/storage-service/src/storage_service_test.rs similarity index 100% rename from core/src/pos/storage/storage-service/src/storage_service_test.rs rename to crates/cfxcore/core/src/pos/storage/storage-service/src/storage_service_test.rs diff --git a/core/src/pos/types/Cargo.toml b/crates/cfxcore/core/src/pos/types/Cargo.toml similarity index 84% rename from core/src/pos/types/Cargo.toml rename to crates/cfxcore/core/src/pos/types/Cargo.toml index e73d6bcbd4..21165ee134 100644 --- a/core/src/pos/types/Cargo.toml +++ b/crates/cfxcore/core/src/pos/types/Cargo.toml @@ -31,10 +31,10 @@ static_assertions = "1.1.0" bcs = "0.1.2" diem-crypto = { path = "../crypto/crypto" } diem-crypto-derive = { path = "../crypto/crypto-derive" } -move-core-types = { path = "./move-core-types" } -cfx-types = { path = "../../../../cfx_types"} -pow-types = {path = "./pow-types"} -diem-logger = {path = "../common/logger"} +move-core-types = { path = "move-core-types" } +cfx-types = { path = "../../../../../cfx_types" } +pow-types = {path = "pow-types" } +diem-logger = {path = "../common/logger" } [dev-dependencies] regex = "1.4.3" @@ -43,7 +43,7 @@ proptest-derive = "0.3.0" serde_json = "1.0.64" diem-crypto = { path = "../crypto/crypto", features = ["fuzzing"] } -move-core-types = { path = "./move-core-types", features = ["fuzzing"] } +move-core-types = { path = "move-core-types", features = ["fuzzing"] } [features] default = [] diff --git a/core/src/pos/types/executor-types/Cargo.toml b/crates/cfxcore/core/src/pos/types/executor-types/Cargo.toml similarity index 94% rename from core/src/pos/types/executor-types/Cargo.toml rename to crates/cfxcore/core/src/pos/types/executor-types/Cargo.toml index 9a72f64968..2cc248b56f 100644 --- a/core/src/pos/types/executor-types/Cargo.toml +++ b/crates/cfxcore/core/src/pos/types/executor-types/Cargo.toml @@ -17,7 +17,7 @@ thiserror = "1.0.24" bcs = "0.1.2" diem-crypto = { path = "../../crypto/crypto" } diem-secure-net = { path = "../../secure/net" } -diem-types = { path = "../../types" } +diem-types = { path = ".." } scratchpad = { path = "../../storage/scratchpad" } storage-interface = { path = "../../storage/storage-interface" } diff --git a/core/src/pos/types/executor-types/src/error.rs b/crates/cfxcore/core/src/pos/types/executor-types/src/error.rs similarity index 100% rename from core/src/pos/types/executor-types/src/error.rs rename to crates/cfxcore/core/src/pos/types/executor-types/src/error.rs diff --git a/core/src/pos/types/executor-types/src/lib.rs b/crates/cfxcore/core/src/pos/types/executor-types/src/lib.rs similarity index 99% rename from core/src/pos/types/executor-types/src/lib.rs rename to crates/cfxcore/core/src/pos/types/executor-types/src/lib.rs index d03f739d0a..f3f3462f15 100644 --- a/core/src/pos/types/executor-types/src/lib.rs +++ b/crates/cfxcore/core/src/pos/types/executor-types/src/lib.rs @@ -153,8 +153,7 @@ impl StateComputeResult { compute_status: Vec, transaction_info_hashes: Vec, pivot_decision: Option, - ) -> Self - { + ) -> Self { Self { root_hash, frozen_subtree_roots, @@ -273,8 +272,7 @@ impl ExecutedTrees { InMemoryAccumulator, >, pos_state: PosState, - ) -> Self - { + ) -> Self { Self { state_tree, transaction_accumulator, @@ -305,8 +303,7 @@ impl ExecutedTrees { state_root_hash: HashValue, frozen_subtrees_in_accumulator: Vec, num_leaves_in_accumulator: u64, pos_state: PosState, - ) -> ExecutedTrees - { + ) -> ExecutedTrees { ExecutedTrees { state_tree: Arc::new(SparseMerkleTree::new(state_root_hash)), transaction_accumulator: Arc::new( diff --git a/core/src/pos/types/executor-types/src/processed_vm_output.rs b/crates/cfxcore/core/src/pos/types/executor-types/src/processed_vm_output.rs similarity index 98% rename from core/src/pos/types/executor-types/src/processed_vm_output.rs rename to crates/cfxcore/core/src/pos/types/executor-types/src/processed_vm_output.rs index 613cc080ac..e8d6e86fda 100644 --- a/core/src/pos/types/executor-types/src/processed_vm_output.rs +++ b/crates/cfxcore/core/src/pos/types/executor-types/src/processed_vm_output.rs @@ -61,8 +61,7 @@ impl TransactionData { state_root_hash: HashValue, event_tree: Arc>, gas_used: u64, txn_info_hash: Option, - ) -> Self - { + ) -> Self { TransactionData { account_blobs, events, @@ -115,8 +114,7 @@ impl ProcessedVMOutput { transaction_data: Vec, executed_trees: ExecutedTrees, epoch_state: Option, pivot_block: Option, - ) -> Self - { + ) -> Self { ProcessedVMOutput { transaction_data, executed_trees, @@ -146,8 +144,7 @@ impl ProcessedVMOutput { pub fn compute_result( &self, parent_frozen_subtree_roots: Vec, parent_num_leaves: u64, - ) -> StateComputeResult - { + ) -> StateComputeResult { let txn_accu = self.executed_trees().txn_accumulator(); // Now that we have the root hash and execution status we can send the // response to consensus. diff --git a/core/src/pos/types/move-core-types/Cargo.toml b/crates/cfxcore/core/src/pos/types/move-core-types/Cargo.toml similarity index 94% rename from core/src/pos/types/move-core-types/Cargo.toml rename to crates/cfxcore/core/src/pos/types/move-core-types/Cargo.toml index 1cd63dcfef..2146855a5b 100644 --- a/core/src/pos/types/move-core-types/Cargo.toml +++ b/crates/cfxcore/core/src/pos/types/move-core-types/Cargo.toml @@ -21,7 +21,7 @@ rand = "0.8.3" ref-cast = "1.0.6" serde = { version = "1.0.124", default-features = false } serde_bytes = "0.11.5" -cfx-types = { path = "../../../../../cfx_types" } +cfx-types = { path = "../../../../../../cfx_types" } [dev-dependencies] proptest = "1.0.0" diff --git a/core/src/pos/types/move-core-types/src/account_address.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/account_address.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/account_address.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/account_address.rs diff --git a/core/src/pos/types/move-core-types/src/effects.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/effects.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/effects.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/effects.rs diff --git a/core/src/pos/types/move-core-types/src/gas_schedule.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/gas_schedule.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/gas_schedule.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/gas_schedule.rs diff --git a/core/src/pos/types/move-core-types/src/identifier.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/identifier.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/identifier.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/identifier.rs diff --git a/core/src/pos/types/move-core-types/src/language_storage.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/language_storage.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/language_storage.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/language_storage.rs diff --git a/core/src/pos/types/move-core-types/src/lib.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/lib.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/lib.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/lib.rs diff --git a/core/src/pos/types/move-core-types/src/move_resource.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/move_resource.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/move_resource.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/move_resource.rs diff --git a/core/src/pos/types/move-core-types/src/parser.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/parser.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/parser.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/parser.rs diff --git a/core/src/pos/types/move-core-types/src/proptest_types.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/proptest_types.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/proptest_types.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/proptest_types.rs diff --git a/core/src/pos/types/move-core-types/src/transaction_argument.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/transaction_argument.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/transaction_argument.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/transaction_argument.rs diff --git a/core/src/pos/types/move-core-types/src/unit_tests/identifier_test.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/unit_tests/identifier_test.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/unit_tests/identifier_test.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/unit_tests/identifier_test.rs diff --git a/core/src/pos/types/move-core-types/src/unit_tests/language_storage_test.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/unit_tests/language_storage_test.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/unit_tests/language_storage_test.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/unit_tests/language_storage_test.rs diff --git a/core/src/pos/types/move-core-types/src/unit_tests/mod.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/unit_tests/mod.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/unit_tests/mod.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/unit_tests/mod.rs diff --git a/core/src/pos/types/move-core-types/src/value.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/value.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/value.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/value.rs diff --git a/core/src/pos/types/move-core-types/src/vm_status.rs b/crates/cfxcore/core/src/pos/types/move-core-types/src/vm_status.rs similarity index 100% rename from core/src/pos/types/move-core-types/src/vm_status.rs rename to crates/cfxcore/core/src/pos/types/move-core-types/src/vm_status.rs diff --git a/core/src/pos/types/pow-types/Cargo.toml b/crates/cfxcore/core/src/pos/types/pow-types/Cargo.toml similarity index 84% rename from core/src/pos/types/pow-types/Cargo.toml rename to crates/cfxcore/core/src/pos/types/pow-types/Cargo.toml index 0f57a05f73..7783995561 100644 --- a/core/src/pos/types/pow-types/Cargo.toml +++ b/crates/cfxcore/core/src/pos/types/pow-types/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -cfx-types = {path = "../../../../../cfx_types"} +cfx-types = {path = "../../../../../../cfx_types" } async-trait = "0.1" anyhow = "1.0.38" serde = "1.0" diff --git a/core/src/pos/types/pow-types/src/lib.rs b/crates/cfxcore/core/src/pos/types/pow-types/src/lib.rs similarity index 97% rename from core/src/pos/types/pow-types/src/lib.rs rename to crates/cfxcore/core/src/pos/types/pow-types/src/lib.rs index 117b5101fa..70a8d48497 100644 --- a/core/src/pos/types/pow-types/src/lib.rs +++ b/crates/cfxcore/core/src/pos/types/pow-types/src/lib.rs @@ -59,8 +59,7 @@ impl PowInterface for FakePowHandler { fn get_staking_events( &self, _parent_height: u64, _me_height: u64, _parent_decision: H256, _me_decision: H256, - ) -> Result> - { + ) -> Result> { todo!() } diff --git a/core/src/pos/types/src/access_path.rs b/crates/cfxcore/core/src/pos/types/src/access_path.rs similarity index 100% rename from core/src/pos/types/src/access_path.rs rename to crates/cfxcore/core/src/pos/types/src/access_path.rs diff --git a/core/src/pos/types/src/account_address.rs b/crates/cfxcore/core/src/pos/types/src/account_address.rs similarity index 100% rename from core/src/pos/types/src/account_address.rs rename to crates/cfxcore/core/src/pos/types/src/account_address.rs diff --git a/core/src/pos/types/src/account_config/constants/account.rs b/crates/cfxcore/core/src/pos/types/src/account_config/constants/account.rs similarity index 100% rename from core/src/pos/types/src/account_config/constants/account.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/constants/account.rs diff --git a/core/src/pos/types/src/account_config/constants/addresses.rs b/crates/cfxcore/core/src/pos/types/src/account_config/constants/addresses.rs similarity index 100% rename from core/src/pos/types/src/account_config/constants/addresses.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/constants/addresses.rs diff --git a/core/src/pos/types/src/account_config/constants/coins.rs b/crates/cfxcore/core/src/pos/types/src/account_config/constants/coins.rs similarity index 100% rename from core/src/pos/types/src/account_config/constants/coins.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/constants/coins.rs diff --git a/core/src/pos/types/src/account_config/constants/diem.rs b/crates/cfxcore/core/src/pos/types/src/account_config/constants/diem.rs similarity index 100% rename from core/src/pos/types/src/account_config/constants/diem.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/constants/diem.rs diff --git a/core/src/pos/types/src/account_config/constants/event.rs b/crates/cfxcore/core/src/pos/types/src/account_config/constants/event.rs similarity index 100% rename from core/src/pos/types/src/account_config/constants/event.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/constants/event.rs diff --git a/core/src/pos/types/src/account_config/constants/mod.rs b/crates/cfxcore/core/src/pos/types/src/account_config/constants/mod.rs similarity index 100% rename from core/src/pos/types/src/account_config/constants/mod.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/constants/mod.rs diff --git a/core/src/pos/types/src/account_config/mod.rs b/crates/cfxcore/core/src/pos/types/src/account_config/mod.rs similarity index 100% rename from core/src/pos/types/src/account_config/mod.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/mod.rs diff --git a/core/src/pos/types/src/account_config/resources/account.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/account.rs similarity index 99% rename from core/src/pos/types/src/account_config/resources/account.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/account.rs index 49a49bd5e9..f3e6a2442d 100644 --- a/core/src/pos/types/src/account_config/resources/account.rs +++ b/crates/cfxcore/core/src/pos/types/src/account_config/resources/account.rs @@ -38,8 +38,7 @@ impl AccountResource { withdrawal_capability: Option, key_rotation_capability: Option, sent_events: EventHandle, received_events: EventHandle, - ) -> Self - { + ) -> Self { AccountResource { sequence_number, withdrawal_capability, diff --git a/core/src/pos/types/src/account_config/resources/balance.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/balance.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/balance.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/balance.rs diff --git a/core/src/pos/types/src/account_config/resources/chain_id.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/chain_id.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/chain_id.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/chain_id.rs diff --git a/core/src/pos/types/src/account_config/resources/currency_info.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/currency_info.rs similarity index 99% rename from core/src/pos/types/src/account_config/resources/currency_info.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/currency_info.rs index 7e99f306e5..0a10dcef14 100644 --- a/core/src/pos/types/src/account_config/resources/currency_info.rs +++ b/crates/cfxcore/core/src/pos/types/src/account_config/resources/currency_info.rs @@ -51,8 +51,7 @@ impl CurrencyInfoResource { burn_events: EventHandle, preburn_events: EventHandle, cancel_burn_events: EventHandle, exchange_rate_update_events: EventHandle, - ) -> Self - { + ) -> Self { Self { total_value, preburn_value, diff --git a/core/src/pos/types/src/account_config/resources/designated_dealer.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/designated_dealer.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/designated_dealer.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/designated_dealer.rs diff --git a/core/src/pos/types/src/account_config/resources/dual_attestation.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/dual_attestation.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/dual_attestation.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/dual_attestation.rs diff --git a/core/src/pos/types/src/account_config/resources/freezing_bit.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/freezing_bit.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/freezing_bit.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/freezing_bit.rs diff --git a/core/src/pos/types/src/account_config/resources/key_rotation_capability.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/key_rotation_capability.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/key_rotation_capability.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/key_rotation_capability.rs diff --git a/core/src/pos/types/src/account_config/resources/mod.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/mod.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/mod.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/mod.rs diff --git a/core/src/pos/types/src/account_config/resources/preburn_balance.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/preburn_balance.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/preburn_balance.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/preburn_balance.rs diff --git a/core/src/pos/types/src/account_config/resources/preburn_queue.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/preburn_queue.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/preburn_queue.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/preburn_queue.rs diff --git a/core/src/pos/types/src/account_config/resources/preburn_with_metadata.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/preburn_with_metadata.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/preburn_with_metadata.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/preburn_with_metadata.rs diff --git a/core/src/pos/types/src/account_config/resources/role.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/role.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/role.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/role.rs diff --git a/core/src/pos/types/src/account_config/resources/role_id.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/role_id.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/role_id.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/role_id.rs diff --git a/core/src/pos/types/src/account_config/resources/vasp.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/vasp.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/vasp.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/vasp.rs diff --git a/core/src/pos/types/src/account_config/resources/withdraw_capability.rs b/crates/cfxcore/core/src/pos/types/src/account_config/resources/withdraw_capability.rs similarity index 100% rename from core/src/pos/types/src/account_config/resources/withdraw_capability.rs rename to crates/cfxcore/core/src/pos/types/src/account_config/resources/withdraw_capability.rs diff --git a/core/src/pos/types/src/account_state.rs b/crates/cfxcore/core/src/pos/types/src/account_state.rs similarity index 99% rename from core/src/pos/types/src/account_state.rs rename to crates/cfxcore/core/src/pos/types/src/account_state.rs index 223f5896e3..74bf66e1f1 100644 --- a/core/src/pos/types/src/account_state.rs +++ b/crates/cfxcore/core/src/pos/types/src/account_state.rs @@ -334,8 +334,7 @@ impl TryFrom<(&AccountResource, &BalanceResource)> for AccountState { &AccountResource, &BalanceResource, ), - ) -> Result - { + ) -> Result { let mut btree_map: BTreeMap, Vec> = BTreeMap::new(); btree_map.insert( AccountResource::resource_path(), diff --git a/core/src/pos/types/src/account_state_blob.rs b/crates/cfxcore/core/src/pos/types/src/account_state_blob.rs similarity index 98% rename from core/src/pos/types/src/account_state_blob.rs rename to crates/cfxcore/core/src/pos/types/src/account_state_blob.rs index b3c3957385..5c728d2e6e 100644 --- a/core/src/pos/types/src/account_state_blob.rs +++ b/crates/cfxcore/core/src/pos/types/src/account_state_blob.rs @@ -95,8 +95,7 @@ impl TryFrom<(&AccountResource, &BalanceResource)> for AccountStateBlob { &AccountResource, &BalanceResource, ), - ) -> Result - { + ) -> Result { Self::try_from(&AccountState::try_from(( account_resource, balance_resource, @@ -158,8 +157,7 @@ impl AccountStateWithProof { pub fn new( version: Version, blob: Option, proof: AccountStateProof, - ) -> Self - { + ) -> Self { Self { version, blob, @@ -179,8 +177,7 @@ impl AccountStateWithProof { pub fn verify( &self, ledger_info: &LedgerInfo, version: Version, address: AccountAddress, - ) -> Result<()> - { + ) -> Result<()> { ensure!( self.version == version, "State version ({}) is not expected ({}).", diff --git a/core/src/pos/types/src/bin/lock_status_tests.rs b/crates/cfxcore/core/src/pos/types/src/bin/lock_status_tests.rs similarity index 100% rename from core/src/pos/types/src/bin/lock_status_tests.rs rename to crates/cfxcore/core/src/pos/types/src/bin/lock_status_tests.rs diff --git a/core/src/pos/types/src/block_info.rs b/crates/cfxcore/core/src/pos/types/src/block_info.rs similarity index 99% rename from core/src/pos/types/src/block_info.rs rename to crates/cfxcore/core/src/pos/types/src/block_info.rs index 0f3c457cfb..c840796f7a 100644 --- a/core/src/pos/types/src/block_info.rs +++ b/crates/cfxcore/core/src/pos/types/src/block_info.rs @@ -67,8 +67,7 @@ impl BlockInfo { version: Version, timestamp_usecs: u64, next_epoch_state: Option, pivot: Option, - ) -> Self - { + ) -> Self { Self { epoch, round, diff --git a/core/src/pos/types/src/block_metadata.rs b/crates/cfxcore/core/src/pos/types/src/block_metadata.rs similarity index 98% rename from core/src/pos/types/src/block_metadata.rs rename to crates/cfxcore/core/src/pos/types/src/block_metadata.rs index 4d6a5f39aa..2885f76d4d 100644 --- a/core/src/pos/types/src/block_metadata.rs +++ b/crates/cfxcore/core/src/pos/types/src/block_metadata.rs @@ -42,8 +42,7 @@ impl BlockMetadata { pub fn new( id: HashValue, round: u64, timestamp_usecs: u64, previous_block_votes: Vec, proposer: AccountAddress, - ) -> Self - { + ) -> Self { Self { id, round, @@ -110,8 +109,7 @@ impl NewBlockEvent { pub fn new( round: u64, proposer: AccountAddress, votes: Vec, timestamp: u64, - ) -> Self - { + ) -> Self { Self { round, proposer, diff --git a/core/src/pos/types/src/chain_id.rs b/crates/cfxcore/core/src/pos/types/src/chain_id.rs similarity index 100% rename from core/src/pos/types/src/chain_id.rs rename to crates/cfxcore/core/src/pos/types/src/chain_id.rs diff --git a/core/src/pos/types/src/committed_block.rs b/crates/cfxcore/core/src/pos/types/src/committed_block.rs similarity index 100% rename from core/src/pos/types/src/committed_block.rs rename to crates/cfxcore/core/src/pos/types/src/committed_block.rs diff --git a/core/src/pos/types/src/contract_event.rs b/crates/cfxcore/core/src/pos/types/src/contract_event.rs similarity index 99% rename from core/src/pos/types/src/contract_event.rs rename to crates/cfxcore/core/src/pos/types/src/contract_event.rs index 58cc278eeb..50990695ad 100644 --- a/core/src/pos/types/src/contract_event.rs +++ b/crates/cfxcore/core/src/pos/types/src/contract_event.rs @@ -113,8 +113,7 @@ impl EventWithProof { pub fn new( transaction_version: Version, event_index: u64, event: ContractEvent, proof: EventProof, - ) -> Self - { + ) -> Self { Self { transaction_version, event_index, @@ -136,8 +135,7 @@ impl EventWithProof { pub fn verify( &self, ledger_info: &LedgerInfo, event_key: &EventKey, _sequence_number: u64, transaction_version: Version, event_index: u64, - ) -> Result<()> - { + ) -> Result<()> { ensure!( self.event.key() == event_key, "Event key ({}) not expected ({}).", diff --git a/core/src/pos/types/src/diem_timestamp.rs b/crates/cfxcore/core/src/pos/types/src/diem_timestamp.rs similarity index 100% rename from core/src/pos/types/src/diem_timestamp.rs rename to crates/cfxcore/core/src/pos/types/src/diem_timestamp.rs diff --git a/core/src/pos/types/src/epoch_change.rs b/crates/cfxcore/core/src/pos/types/src/epoch_change.rs similarity index 100% rename from core/src/pos/types/src/epoch_change.rs rename to crates/cfxcore/core/src/pos/types/src/epoch_change.rs diff --git a/core/src/pos/types/src/epoch_state.rs b/crates/cfxcore/core/src/pos/types/src/epoch_state.rs similarity index 100% rename from core/src/pos/types/src/epoch_state.rs rename to crates/cfxcore/core/src/pos/types/src/epoch_state.rs diff --git a/core/src/pos/types/src/event.rs b/crates/cfxcore/core/src/pos/types/src/event.rs similarity index 100% rename from core/src/pos/types/src/event.rs rename to crates/cfxcore/core/src/pos/types/src/event.rs diff --git a/core/src/pos/types/src/ledger_info.rs b/crates/cfxcore/core/src/pos/types/src/ledger_info.rs similarity index 99% rename from core/src/pos/types/src/ledger_info.rs rename to crates/cfxcore/core/src/pos/types/src/ledger_info.rs index 61cb647567..bff01ea9d6 100644 --- a/core/src/pos/types/src/ledger_info.rs +++ b/crates/cfxcore/core/src/pos/types/src/ledger_info.rs @@ -154,8 +154,7 @@ impl LedgerInfoWithSignatures { pub fn new( ledger_info: LedgerInfo, signatures: BTreeMap, - ) -> Self - { + ) -> Self { LedgerInfoWithSignatures::V0(LedgerInfoWithV0::new( ledger_info, signatures, @@ -216,8 +215,7 @@ impl LedgerInfoWithV0 { pub fn new( ledger_info: LedgerInfo, signatures: BTreeMap, - ) -> Self - { + ) -> Self { LedgerInfoWithV0 { ledger_info, signatures, diff --git a/core/src/pos/types/src/lib.rs b/crates/cfxcore/core/src/pos/types/src/lib.rs similarity index 100% rename from core/src/pos/types/src/lib.rs rename to crates/cfxcore/core/src/pos/types/src/lib.rs diff --git a/core/src/pos/types/src/mempool_status.rs b/crates/cfxcore/core/src/pos/types/src/mempool_status.rs similarity index 100% rename from core/src/pos/types/src/mempool_status.rs rename to crates/cfxcore/core/src/pos/types/src/mempool_status.rs diff --git a/core/src/pos/types/src/move_resource.rs b/crates/cfxcore/core/src/pos/types/src/move_resource.rs similarity index 100% rename from core/src/pos/types/src/move_resource.rs rename to crates/cfxcore/core/src/pos/types/src/move_resource.rs diff --git a/core/src/pos/types/src/network_address/encrypted.rs b/crates/cfxcore/core/src/pos/types/src/network_address/encrypted.rs similarity index 99% rename from core/src/pos/types/src/network_address/encrypted.rs rename to crates/cfxcore/core/src/pos/types/src/network_address/encrypted.rs index ce62b510ae..a0243541e4 100644 --- a/core/src/pos/types/src/network_address/encrypted.rs +++ b/crates/cfxcore/core/src/pos/types/src/network_address/encrypted.rs @@ -161,8 +161,7 @@ impl EncNetworkAddress { addr: NetworkAddress, shared_val_netaddr_key: &Key, key_version: KeyVersion, account: &AccountAddress, seq_num: u64, addr_idx: u32, - ) -> Result - { + ) -> Result { // unpack the NetworkAddress into its base Vec let mut addr_vec: Vec = bcs::to_bytes(&addr)?; @@ -206,8 +205,7 @@ impl EncNetworkAddress { pub fn decrypt( self, shared_val_netaddr_key: &Key, account: &AccountAddress, addr_idx: u32, - ) -> Result - { + ) -> Result { let key_version = self.key_version; let seq_num = self.seq_num; let mut enc_addr = self.enc_addr; diff --git a/core/src/pos/types/src/network_address/mod.rs b/crates/cfxcore/core/src/pos/types/src/network_address/mod.rs similarity index 99% rename from core/src/pos/types/src/network_address/mod.rs rename to crates/cfxcore/core/src/pos/types/src/network_address/mod.rs index bbbef373e3..3b5d31eb41 100644 --- a/core/src/pos/types/src/network_address/mod.rs +++ b/crates/cfxcore/core/src/pos/types/src/network_address/mod.rs @@ -223,8 +223,7 @@ impl NetworkAddress { pub fn encrypt( self, shared_val_netaddr_key: &Key, key_version: KeyVersion, account: &AccountAddress, seq_num: u64, addr_idx: u32, - ) -> Result - { + ) -> Result { EncNetworkAddress::encrypt( self, shared_val_netaddr_key, @@ -315,8 +314,7 @@ impl NetworkAddress { pub fn rotate_noise_public_key( &mut self, to_replace: &x25519::PublicKey, new_public_key: &x25519::PublicKey, - ) - { + ) { for protocol in self.0.iter_mut() { // Replace the public key in any Noise protocols that match the key if let Protocol::NoiseIK(public_key) = protocol { diff --git a/core/src/pos/types/src/on_chain_config/diem_version.rs b/crates/cfxcore/core/src/pos/types/src/on_chain_config/diem_version.rs similarity index 100% rename from core/src/pos/types/src/on_chain_config/diem_version.rs rename to crates/cfxcore/core/src/pos/types/src/on_chain_config/diem_version.rs diff --git a/core/src/pos/types/src/on_chain_config/mod.rs b/crates/cfxcore/core/src/pos/types/src/on_chain_config/mod.rs similarity index 100% rename from core/src/pos/types/src/on_chain_config/mod.rs rename to crates/cfxcore/core/src/pos/types/src/on_chain_config/mod.rs diff --git a/core/src/pos/types/src/on_chain_config/registered_currencies.rs b/crates/cfxcore/core/src/pos/types/src/on_chain_config/registered_currencies.rs similarity index 100% rename from core/src/pos/types/src/on_chain_config/registered_currencies.rs rename to crates/cfxcore/core/src/pos/types/src/on_chain_config/registered_currencies.rs diff --git a/core/src/pos/types/src/on_chain_config/validator_set.rs b/crates/cfxcore/core/src/pos/types/src/on_chain_config/validator_set.rs similarity index 100% rename from core/src/pos/types/src/on_chain_config/validator_set.rs rename to crates/cfxcore/core/src/pos/types/src/on_chain_config/validator_set.rs diff --git a/core/src/pos/types/src/on_chain_config/vm_config.rs b/crates/cfxcore/core/src/pos/types/src/on_chain_config/vm_config.rs similarity index 100% rename from core/src/pos/types/src/on_chain_config/vm_config.rs rename to crates/cfxcore/core/src/pos/types/src/on_chain_config/vm_config.rs diff --git a/core/src/pos/types/src/on_chain_config/vm_publishing_option.rs b/crates/cfxcore/core/src/pos/types/src/on_chain_config/vm_publishing_option.rs similarity index 100% rename from core/src/pos/types/src/on_chain_config/vm_publishing_option.rs rename to crates/cfxcore/core/src/pos/types/src/on_chain_config/vm_publishing_option.rs diff --git a/core/src/pos/types/src/proof/accumulator/accumulator_test.rs b/crates/cfxcore/core/src/pos/types/src/proof/accumulator/accumulator_test.rs similarity index 100% rename from core/src/pos/types/src/proof/accumulator/accumulator_test.rs rename to crates/cfxcore/core/src/pos/types/src/proof/accumulator/accumulator_test.rs diff --git a/core/src/pos/types/src/proof/accumulator/mod.rs b/crates/cfxcore/core/src/pos/types/src/proof/accumulator/mod.rs similarity index 99% rename from core/src/pos/types/src/proof/accumulator/mod.rs rename to crates/cfxcore/core/src/pos/types/src/proof/accumulator/mod.rs index ef483e4ab7..75dd9f37fb 100644 --- a/core/src/pos/types/src/proof/accumulator/mod.rs +++ b/crates/cfxcore/core/src/pos/types/src/proof/accumulator/mod.rs @@ -113,8 +113,7 @@ where H: CryptoHasher fn append_one( frozen_subtree_roots: &mut Vec, num_existing_leaves: LeafCount, leaf: HashValue, - ) - { + ) { // For example, this accumulator originally had N = 7 leaves. Appending // a leaf is like adding one to this number N: 0b0111 + 1 = // 0b1000. Every time we carry a bit to the left we merge the diff --git a/core/src/pos/types/src/proof/definition.rs b/crates/cfxcore/core/src/pos/types/src/proof/definition.rs similarity index 99% rename from core/src/pos/types/src/proof/definition.rs rename to crates/cfxcore/core/src/pos/types/src/proof/definition.rs index c29018a01e..a1ed1a103e 100644 --- a/core/src/pos/types/src/proof/definition.rs +++ b/crates/cfxcore/core/src/pos/types/src/proof/definition.rs @@ -71,8 +71,7 @@ where H: CryptoHasher pub fn verify( &self, expected_root_hash: HashValue, element_hash: HashValue, element_index: u64, - ) -> Result<()> - { + ) -> Result<()> { ensure!( self.siblings.len() <= MAX_ACCUMULATOR_PROOF_DEPTH, "Accumulator proof has more than {} ({}) siblings.", @@ -193,8 +192,7 @@ where V: CryptoHash pub fn verify( &self, expected_root_hash: HashValue, element_key: HashValue, element_value: Option<&V>, - ) -> Result<()> - { + ) -> Result<()> { ensure!( self.siblings.len() <= HashValue::LENGTH_IN_BITS, "Sparse Merkle Tree proof has more than {} ({}) siblings.", @@ -368,8 +366,7 @@ where H: CryptoHasher pub fn verify( &self, expected_root_hash: HashValue, first_leaf_index: Option, leaf_hashes: &[HashValue], - ) -> Result<()> - { + ) -> Result<()> { if first_leaf_index.is_none() { ensure!( leaf_hashes.is_empty(), @@ -553,8 +550,7 @@ impl TransactionInfoWithProof { pub fn new( ledger_info_to_transaction_info_proof: TransactionAccumulatorProof, transaction_info: TransactionInfo, - ) -> Self - { + ) -> Self { Self { ledger_info_to_transaction_info_proof, transaction_info, @@ -609,8 +605,7 @@ impl AccountStateProof { pub fn new( transaction_info_with_proof: TransactionInfoWithProof, transaction_info_to_account_proof: SparseMerkleProof, - ) -> Self - { + ) -> Self { AccountStateProof { transaction_info_with_proof, transaction_info_to_account_proof, @@ -637,8 +632,7 @@ impl AccountStateProof { &self, ledger_info: &LedgerInfo, state_version: Version, account_address_hash: HashValue, account_state_blob: Option<&AccountStateBlob>, - ) -> Result<()> - { + ) -> Result<()> { self.transaction_info_to_account_proof.verify( self.transaction_info_with_proof .transaction_info @@ -674,8 +668,7 @@ impl EventProof { pub fn new( transaction_info_with_proof: TransactionInfoWithProof, transaction_info_to_event_proof: EventAccumulatorProof, - ) -> Self - { + ) -> Self { EventProof { transaction_info_with_proof, transaction_info_to_event_proof, @@ -692,8 +685,7 @@ impl EventProof { &self, ledger_info: &LedgerInfo, event_hash: HashValue, transaction_version: Version, event_version_within_transaction: Version, - ) -> Result<()> - { + ) -> Result<()> { self.transaction_info_to_event_proof.verify( self.transaction_info_with_proof .transaction_info() @@ -727,8 +719,7 @@ impl TransactionListProof { pub fn new( ledger_info_to_transaction_infos_proof: TransactionAccumulatorRangeProof, transaction_infos: Vec, - ) -> Self - { + ) -> Self { Self { ledger_info_to_transaction_infos_proof, transaction_infos, @@ -765,8 +756,7 @@ impl TransactionListProof { &self, ledger_info: &LedgerInfo, first_transaction_version: Option, transaction_hashes: &[HashValue], - ) -> Result<()> - { + ) -> Result<()> { ensure!( self.transaction_infos.len() == transaction_hashes.len(), "The number of TransactionInfo objects ({}) does not match the number of \ @@ -821,8 +811,7 @@ impl AccumulatorExtensionProof { pub fn new( frozen_subtree_roots: Vec, num_leaves: LeafCount, leaves: Vec, - ) -> Self - { + ) -> Self { Self { frozen_subtree_roots, num_leaves, diff --git a/core/src/pos/types/src/proof/mod.rs b/crates/cfxcore/core/src/pos/types/src/proof/mod.rs similarity index 99% rename from core/src/pos/types/src/proof/mod.rs rename to crates/cfxcore/core/src/pos/types/src/proof/mod.rs index 606bdf4fb5..20df8d021e 100644 --- a/core/src/pos/types/src/proof/mod.rs +++ b/crates/cfxcore/core/src/pos/types/src/proof/mod.rs @@ -50,8 +50,7 @@ fn verify_transaction_info( ledger_info: &LedgerInfo, transaction_version: Version, transaction_info: &TransactionInfo, ledger_info_to_transaction_info_proof: &TransactionAccumulatorProof, -) -> Result<()> -{ +) -> Result<()> { ensure!( transaction_version <= ledger_info.version(), "Transaction version {} is newer than LedgerInfo version {}.", diff --git a/core/src/pos/types/src/proof/position/mod.rs b/crates/cfxcore/core/src/pos/types/src/proof/position/mod.rs similarity index 100% rename from core/src/pos/types/src/proof/position/mod.rs rename to crates/cfxcore/core/src/pos/types/src/proof/position/mod.rs diff --git a/core/src/pos/types/src/proof/position/position_test.rs b/crates/cfxcore/core/src/pos/types/src/proof/position/position_test.rs similarity index 100% rename from core/src/pos/types/src/proof/position/position_test.rs rename to crates/cfxcore/core/src/pos/types/src/proof/position/position_test.rs diff --git a/core/src/pos/types/src/proof/proptest_proof.rs b/crates/cfxcore/core/src/pos/types/src/proof/proptest_proof.rs similarity index 100% rename from core/src/pos/types/src/proof/proptest_proof.rs rename to crates/cfxcore/core/src/pos/types/src/proof/proptest_proof.rs diff --git a/core/src/pos/types/src/proof/unit_tests/mod.rs b/crates/cfxcore/core/src/pos/types/src/proof/unit_tests/mod.rs similarity index 100% rename from core/src/pos/types/src/proof/unit_tests/mod.rs rename to crates/cfxcore/core/src/pos/types/src/proof/unit_tests/mod.rs diff --git a/core/src/pos/types/src/proof/unit_tests/proof_conversion_test.rs b/crates/cfxcore/core/src/pos/types/src/proof/unit_tests/proof_conversion_test.rs similarity index 100% rename from core/src/pos/types/src/proof/unit_tests/proof_conversion_test.rs rename to crates/cfxcore/core/src/pos/types/src/proof/unit_tests/proof_conversion_test.rs diff --git a/core/src/pos/types/src/proof/unit_tests/proof_test.rs b/crates/cfxcore/core/src/pos/types/src/proof/unit_tests/proof_test.rs similarity index 100% rename from core/src/pos/types/src/proof/unit_tests/proof_test.rs rename to crates/cfxcore/core/src/pos/types/src/proof/unit_tests/proof_test.rs diff --git a/core/src/pos/types/src/proptest_types.rs b/crates/cfxcore/core/src/pos/types/src/proptest_types.rs similarity index 99% rename from core/src/pos/types/src/proptest_types.rs rename to crates/cfxcore/core/src/pos/types/src/proptest_types.rs index 9c7c6a4801..370d4b4d3a 100644 --- a/core/src/pos/types/src/proptest_types.rs +++ b/crates/cfxcore/core/src/pos/types/src/proptest_types.rs @@ -142,8 +142,7 @@ impl AccountInfo { private_key: ConsensusPrivateKey, public_key: ConsensusPublicKey, vrf_private_key: ConsensusVRFPrivateKey, vrf_public_key: ConsensusVRFPublicKey, - ) -> Self - { + ) -> Self { let address = account_address::from_consensus_public_key( &public_key, &vrf_public_key, @@ -177,8 +176,7 @@ impl AccountInfoUniverse { (ConsensusVRFPrivateKey, ConsensusVRFPublicKey), )>, epoch: u64, round: Round, next_version: Version, - ) -> Self - { + ) -> Self { let accounts = keypairs .into_iter() .map( @@ -321,8 +319,7 @@ impl RawTransaction { fn strategy_impl( address_strategy: impl Strategy, payload_strategy: impl Strategy, - ) -> impl Strategy - { + ) -> impl Strategy { // XXX what other constraints do these need to obey? (address_strategy, payload_strategy, any::()).prop_map( |(sender, payload, expiration_time_secs)| { @@ -335,8 +332,7 @@ impl RawTransaction { fn new_raw_transaction( sender: AccountAddress, payload: TransactionPayload, expiration_time_secs: u64, -) -> RawTransaction -{ +) -> RawTransaction { let chain_id = ChainId::test(); match payload { TransactionPayload::Module(module) => RawTransaction::new_module( @@ -422,8 +418,7 @@ impl SignatureCheckedTransaction { vrf_keypair_strategy: impl Strategy< Value = KeyPair, >, - ) -> impl Strategy - { + ) -> impl Strategy { Self::strategy_impl( keypair_strategy, vrf_keypair_strategy, @@ -439,8 +434,7 @@ impl SignatureCheckedTransaction { Value = KeyPair, >, payload_strategy: impl Strategy, - ) -> impl Strategy - { + ) -> impl Strategy { (keypair_strategy, vrf_keypair_strategy, payload_strategy) .prop_flat_map(|(keypair, vrf_keypair, payload)| { let address = account_address::from_consensus_public_key( diff --git a/core/src/pos/types/src/reward_distribution_event.rs b/crates/cfxcore/core/src/pos/types/src/reward_distribution_event.rs similarity index 100% rename from core/src/pos/types/src/reward_distribution_event.rs rename to crates/cfxcore/core/src/pos/types/src/reward_distribution_event.rs diff --git a/core/src/pos/types/src/serde_helper/mod.rs b/crates/cfxcore/core/src/pos/types/src/serde_helper/mod.rs similarity index 100% rename from core/src/pos/types/src/serde_helper/mod.rs rename to crates/cfxcore/core/src/pos/types/src/serde_helper/mod.rs diff --git a/core/src/pos/types/src/serde_helper/vec_bytes.rs b/crates/cfxcore/core/src/pos/types/src/serde_helper/vec_bytes.rs similarity index 100% rename from core/src/pos/types/src/serde_helper/vec_bytes.rs rename to crates/cfxcore/core/src/pos/types/src/serde_helper/vec_bytes.rs diff --git a/core/src/pos/types/src/term_state.rs b/crates/cfxcore/core/src/pos/types/src/term_state.rs similarity index 99% rename from core/src/pos/types/src/term_state.rs rename to crates/cfxcore/core/src/pos/types/src/term_state.rs index 7181093a84..427d7db648 100644 --- a/core/src/pos/types/src/term_state.rs +++ b/crates/cfxcore/core/src/pos/types/src/term_state.rs @@ -501,8 +501,7 @@ impl PosState { initial_seed: Vec, initial_nodes: Vec<(NodeID, u64)>, initial_committee: Vec<(AccountAddress, u64)>, genesis_pivot_decision: PivotBlockDecision, - ) -> Self - { + ) -> Self { let mut node_map = HashMap::new(); let mut node_list = BTreeMap::default(); for (node_id, total_voting_power) in initial_nodes { @@ -738,8 +737,7 @@ impl PosState { pub fn validate_pivot_decision( &self, pivot_decision_tx: &PivotBlockDecision, signature: MultiConsensusSignature, - ) -> Result<()> - { + ) -> Result<()> { if pivot_decision_tx.height <= self.pivot_decision.height { return Err(anyhow!(format!( "Pivot Decision height too small, found[{}], expect[{}]", @@ -1123,8 +1121,7 @@ impl ElectionEvent { pub fn new( public_key: ConsensusPublicKey, vrf_public_key: ConsensusVRFPublicKey, vrf_output: HashValue, start_term: u64, - ) -> Self - { + ) -> Self { Self { node_id: NodeID::new(public_key, vrf_public_key), vrf_output, diff --git a/core/src/pos/types/src/term_state/lock_status.rs b/crates/cfxcore/core/src/pos/types/src/term_state/lock_status.rs similarity index 99% rename from core/src/pos/types/src/term_state/lock_status.rs rename to crates/cfxcore/core/src/pos/types/src/term_state/lock_status.rs index 097ca08937..9c195834f7 100644 --- a/core/src/pos/types/src/term_state/lock_status.rs +++ b/crates/cfxcore/core/src/pos/types/src/term_state/lock_status.rs @@ -181,8 +181,7 @@ impl NodeLockStatus { pub(super) fn new_lock( &mut self, view: View, votes: u64, initialize_mode: bool, update_views: &mut Vec, - ) - { + ) { if votes == 0 { return; } @@ -210,8 +209,7 @@ impl NodeLockStatus { pub(super) fn new_unlock( &mut self, view: View, to_unlock_votes: u64, update_views: &mut Vec, - ) - { + ) { if to_unlock_votes == 0 { return; } diff --git a/core/src/pos/types/src/term_state/pos_state_config.rs b/crates/cfxcore/core/src/pos/types/src/term_state/pos_state_config.rs similarity index 99% rename from core/src/pos/types/src/term_state/pos_state_config.rs rename to crates/cfxcore/core/src/pos/types/src/term_state/pos_state_config.rs index 3308aee10e..b0630dd1e9 100644 --- a/core/src/pos/types/src/term_state/pos_state_config.rs +++ b/crates/cfxcore/core/src/pos/types/src/term_state/pos_state_config.rs @@ -53,8 +53,7 @@ impl PosStateConfig { fix_cip99_in_queue_locked_views: u64, fix_cip99_out_queue_locked_views: u64, nonce_limit_transition_view: u64, max_nonce_per_account: u64, - ) -> Self - { + ) -> Self { Self { round_per_term, term_max_size, diff --git a/core/src/pos/types/src/test_helpers/empty_script.mv b/crates/cfxcore/core/src/pos/types/src/test_helpers/empty_script.mv similarity index 100% rename from core/src/pos/types/src/test_helpers/empty_script.mv rename to crates/cfxcore/core/src/pos/types/src/test_helpers/empty_script.mv diff --git a/core/src/pos/types/src/test_helpers/mod.rs b/crates/cfxcore/core/src/pos/types/src/test_helpers/mod.rs similarity index 100% rename from core/src/pos/types/src/test_helpers/mod.rs rename to crates/cfxcore/core/src/pos/types/src/test_helpers/mod.rs diff --git a/core/src/pos/types/src/test_helpers/transaction_test_helpers.rs b/crates/cfxcore/core/src/pos/types/src/test_helpers/transaction_test_helpers.rs similarity index 95% rename from core/src/pos/types/src/test_helpers/transaction_test_helpers.rs rename to crates/cfxcore/core/src/pos/types/src/test_helpers/transaction_test_helpers.rs index 57ed4bf94c..9ebca7e3db 100644 --- a/core/src/pos/types/src/test_helpers/transaction_test_helpers.rs +++ b/crates/cfxcore/core/src/pos/types/src/test_helpers/transaction_test_helpers.rs @@ -31,8 +31,7 @@ fn expiration_time(seconds: u64) -> u64 { pub fn get_test_signed_module_publishing_transaction( sender: AccountAddress, private_key: &BLSPrivateKey, public_key: BLSPublicKey, module: Module, -) -> SignedTransaction -{ +) -> SignedTransaction { let expiration_time = expiration_time(10); let raw_txn = RawTransaction::new_module( sender, @@ -51,8 +50,7 @@ pub fn get_test_signed_transaction( sender: AccountAddress, private_key: &BLSPrivateKey, public_key: BLSPublicKey, script: Option