diff --git a/Cargo.lock b/Cargo.lock index ca1cc37e93..c7c01b7189 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -980,7 +980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" dependencies = [ "blst", - "byte-slice-cast 1.2.2", + "byte-slice-cast 1.2.3", "ff", "group", "pairing", @@ -1022,9 +1022,9 @@ checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" [[package]] name = "byte-slice-cast" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" +checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" [[package]] name = "byte-tools" @@ -1208,7 +1208,7 @@ version = "2.0.2" dependencies = [ "cfx-types", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "sqlite", "strfmt", "thiserror 2.0.11", @@ -1230,6 +1230,7 @@ dependencies = [ "log", "pow-types", "primitives", + "rlp-bool", "solidity-abi", "typemap-ors", ] @@ -1259,7 +1260,7 @@ dependencies = [ "diem-types", "hex-literal 1.0.0", "impl-tools", - "impl-trait-for-tuples 0.2.2", + "impl-trait-for-tuples 0.2.3", "keccak-hash", "lazy_static", "log", @@ -1270,7 +1271,7 @@ dependencies = [ "pow-types", "primitives", "rayon", - "rlp 0.4.6", + "rlp 0.6.1", "rustc-hex", "sha3-macro", "solidity-abi", @@ -1293,7 +1294,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot 0.12.1", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -1355,7 +1356,8 @@ dependencies = [ "malloc_size_of", "malloc_size_of_derive", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "serde", "strum_macros", @@ -1462,7 +1464,7 @@ dependencies = [ "log", "parity-version", "primitives", - "rand 0.7.3", + "rand 0.8.5", "rustc-hex", "serde", "serde_derive", @@ -1509,7 +1511,7 @@ dependencies = [ "jsonrpc-core", "jsonrpsee", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "serde", "serde_json", "similar-asserts", @@ -1579,7 +1581,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "tiny-keccak 2.0.2", ] @@ -1613,7 +1615,8 @@ dependencies = [ "rand 0.9.0", "rand_chacha 0.9.0", "random-crash", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "rustc-hex", "serde", @@ -1654,10 +1657,10 @@ dependencies = [ name = "cfx-types" version = "0.2.0" dependencies = [ - "ethereum-types 0.9.2", + "ethereum-types 0.15.1", "hex", "keccak-hash", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -1701,7 +1704,7 @@ dependencies = [ "cfx-types", "keccak-hash", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "serde", "solidity-abi", ] @@ -1717,6 +1720,7 @@ dependencies = [ "bls-signatures", "bounded-executor", "byteorder", + "bytes 1.9.0", "cached-pos-ledger-db", "cfx-addr", "cfx-bytes", @@ -1792,7 +1796,8 @@ dependencies = [ "rand_xorshift 0.4.0", "rangetools", "rayon", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "rustc-hex", "safety-rules", @@ -1868,7 +1873,7 @@ dependencies = [ "parking_lot 0.12.1", "primitives", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "smart-default", "thiserror 2.0.11", @@ -2128,7 +2133,8 @@ dependencies = [ "rand 0.8.5", "rand 0.9.0", "random-crash", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rpassword", "rustc-hex", "secret-store", @@ -2228,7 +2234,7 @@ dependencies = [ "pos-ledger-db", "primitives", "rand 0.8.5", - "rlp 0.4.6", + "rlp 0.6.1", "rpassword", "rustc-hex", "serde_json", @@ -2292,6 +2298,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_format" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -3326,27 +3352,27 @@ dependencies = [ [[package]] name = "ethbloom" -version = "0.9.2" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" +checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" dependencies = [ "crunchy", - "fixed-hash 0.6.1", - "impl-rlp 0.2.1", + "fixed-hash 0.7.0", + "impl-rlp 0.3.0", "impl-serde 0.3.2", "tiny-keccak 2.0.2", ] [[package]] name = "ethbloom" -version = "0.11.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" +checksum = "8c321610643004cf908ec0f5f2aa0d8f1f8e14b540562a2887a1111ff1ecbf7b" dependencies = [ "crunchy", - "fixed-hash 0.7.0", - "impl-rlp 0.3.0", - "impl-serde 0.3.2", + "fixed-hash 0.8.0", + "impl-rlp 0.4.0", + "impl-serde 0.5.0", "tiny-keccak 2.0.2", ] @@ -3370,20 +3396,6 @@ dependencies = [ "uint 0.8.5", ] -[[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 0.2.1", - "impl-serde 0.3.2", - "primitive-types 0.7.3", - "uint 0.8.5", -] - [[package]] name = "ethereum-types" version = "0.12.1" @@ -3398,6 +3410,20 @@ dependencies = [ "uint 0.9.5", ] +[[package]] +name = "ethereum-types" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab15ed80916029f878e0267c3a9f92b67df55e79af370bf66199059ae2b4ee3" +dependencies = [ + "ethbloom 0.14.1", + "fixed-hash 0.8.0", + "impl-rlp 0.4.0", + "impl-serde 0.5.0", + "primitive-types 0.13.1", + "uint 0.10.0", +] + [[package]] name = "executor" version = "0.1.0" @@ -3527,18 +3553,6 @@ dependencies = [ "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", - "static_assertions", -] - [[package]] name = "fixed-hash" version = "0.7.0" @@ -4540,7 +4554,16 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ - "parity-scale-codec 3.6.9", + "parity-scale-codec 3.7.5", +] + +[[package]] +name = "impl-codec" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d40b9d5e17727407e55028eafc22b2dc68781786e6d7eb8a21103f5058e3a14" +dependencies = [ + "parity-scale-codec 3.7.5", ] [[package]] @@ -4561,6 +4584,15 @@ dependencies = [ "rlp 0.5.2", ] +[[package]] +name = "impl-rlp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ed8ad1f3877f7e775b8cbf30ed1bd3209a95401817f19a0eb4402d13f8cf90" +dependencies = [ + "rlp 0.6.1", +] + [[package]] name = "impl-serde" version = "0.2.3" @@ -4579,6 +4611,15 @@ dependencies = [ "serde", ] +[[package]] +name = "impl-serde" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" +dependencies = [ + "serde", +] + [[package]] name = "impl-tools" version = "0.10.0" @@ -4616,13 +4657,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -5113,11 +5154,11 @@ dependencies = [ [[package]] name = "keccak-hash" -version = "0.5.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f58a51ef3df9398cf2434bea8d4eb61fb748d0feb1571f87388579a120a4c8f" +checksum = "3e1b8590eb6148af2ea2d75f38e7d29f5ca970d5a4df456b3ef19b8b415d0264" dependencies = [ - "primitive-types 0.7.3", + "primitive-types 0.13.1", "tiny-keccak 2.0.2", ] @@ -5348,7 +5389,7 @@ dependencies = [ "kvdb", "parking_lot 0.12.1", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", ] @@ -5706,7 +5747,7 @@ dependencies = [ "parking_lot 0.12.1", "priority-send-queue", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -6039,23 +6080,25 @@ checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" dependencies = [ "arrayvec 0.7.4", "bitvec 0.20.4", - "byte-slice-cast 1.2.2", - "impl-trait-for-tuples 0.2.2", + "byte-slice-cast 1.2.3", + "impl-trait-for-tuples 0.2.3", "parity-scale-codec-derive 2.3.1", "serde", ] [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "799781ae679d79a948e13d4824a40970bfa500058d245760dd857301059810fa" dependencies = [ "arrayvec 0.7.4", "bitvec 1.0.1", - "byte-slice-cast 1.2.2", - "impl-trait-for-tuples 0.2.2", - "parity-scale-codec-derive 3.6.9", + "byte-slice-cast 1.2.3", + "const_format", + "impl-trait-for-tuples 0.2.3", + "parity-scale-codec-derive 3.7.5", + "rustversion", "serde", ] @@ -6073,14 +6116,14 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "34b4653168b563151153c9e4c08ebed57fb8262bebfa79711552fa983c623e7a" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -6560,19 +6603,6 @@ dependencies = [ "uint 0.8.5", ] -[[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 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" @@ -6597,6 +6627,19 @@ dependencies = [ "uint 0.9.5", ] +[[package]] +name = "primitive-types" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" +dependencies = [ + "fixed-hash 0.8.0", + "impl-codec 0.7.1", + "impl-rlp 0.4.0", + "impl-serde 0.5.0", + "uint 0.10.0", +] + [[package]] name = "primitives" version = "0.2.0" @@ -6614,7 +6657,8 @@ dependencies = [ "malloc_size_of", "once_cell", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "serde", "serde_derive", @@ -6646,15 +6690,6 @@ dependencies = [ "toml_edit 0.19.7", ] -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro-crate" version = "3.2.0" @@ -6690,9 +6725,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -6766,9 +6801,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -7375,6 +7410,25 @@ dependencies = [ "rustc-hex", ] +[[package]] +name = "rlp" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa24e92bb2a83198bb76d661a71df9f7076b8c420b8696e4d3d97d50d94479e3" +dependencies = [ + "bytes 1.9.0", + "rustc-hex", +] + +[[package]] +name = "rlp-bool" +version = "3.0.0" +dependencies = [ + "malloc_size_of", + "malloc_size_of_derive", + "rlp 0.6.1", +] + [[package]] name = "rlp-derive" version = "0.2.0" @@ -7426,7 +7480,7 @@ dependencies = [ "num-bigint 0.4.4", "num-integer", "num-traits", - "parity-scale-codec 3.6.9", + "parity-scale-codec 3.7.5", "primitive-types 0.12.2", "proptest", "rand 0.8.5", @@ -7862,9 +7916,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] @@ -7910,9 +7964,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -8824,17 +8878,6 @@ dependencies = [ "winnow 0.3.6", ] -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap 2.8.0", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.20" @@ -9000,7 +9043,7 @@ dependencies = [ "parking_lot 0.12.1", "primitives", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", "rustc-hex", "secret-store", ] @@ -9050,6 +9093,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "uint" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unarray" version = "0.1.4" @@ -9616,15 +9671,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "0.6.18" diff --git a/Cargo.toml b/Cargo.toml index 8e92745f2b..528f30e1a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ members = [ "crates/util/treap-map", "crates/util/version", "crates/util/serde_utils", + "crates/util/rlp_bool", "crates/execution/geth-tracer", "crates/rpc/rpc-eth-types", "crates/rpc/rpc-primitives", @@ -172,6 +173,7 @@ cfx-stratum = { path = "./crates/stratum" } txgen = { path = "./crates/transactiongen" } blockgen = { path = "./crates/blockgen" } serde-utils = { path = "./crates/util/serde_utils" } +rlp-bool = { path = "./crates/util/rlp_bool" } db = { path = "./crates/dbs/db" } cfx-db-errors = { path = "./crates/dbs/db-errors" } cfx-statedb = { path = "./crates/dbs/statedb" } @@ -327,7 +329,7 @@ reqwest = "0.12" # crypto & hash #fixed-hash = "0.5" -keccak-hash = "0.5" +keccak-hash = "0.11.0" tiny-keccak = "2.0" bls-signatures = { git = "https://github.com/Conflux-Chain/bls-signatures.git", rev = "fb52187df92d27c365642cb7e7b2aaf60437cf9c", default-features = false, features = [ "multicore", @@ -426,12 +428,12 @@ chrono = "0.4" duration-str = "0.17" # parity crates -rlp = "0.4.0" +rlp = "0.6.1" rlp_derive = { package = "rlp-derive", version = "0.2.0" } panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "09da4dfeecd754df2034d4e71a260277aaaf9783" } dir = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "09da4dfeecd754df2034d4e71a260277aaaf9783" } unexpected = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "09da4dfeecd754df2034d4e71a260277aaaf9783" } -ethereum-types = "0.9" +ethereum-types = "0.15.1" parity-wordlist = "1.3.0" parity-crypto = "0.9.0" parity-path = "0.1" diff --git a/crates/cfx_key/src/extended.rs b/crates/cfx_key/src/extended.rs index 979cd408b6..eb860ab5c5 100644 --- a/crates/cfx_key/src/extended.rs +++ b/crates/cfx_key/src/extended.rs @@ -294,7 +294,7 @@ mod derivation { // 0x00 (padding) -- private_key -- index // 0 -- 1..33 -- 33..end - private.to_big_endian(&mut data[1..33]); + private.write_as_big_endian(&mut data[1..33]); index.store(&mut data[33..(33 + T::len())]); hmac_pair(&data, private_key, chain_code) diff --git a/crates/cfx_types/src/contract_address.rs b/crates/cfx_types/src/contract_address.rs index cdba545803..8fb8db5524 100644 --- a/crates/cfx_types/src/contract_address.rs +++ b/crates/cfx_types/src/contract_address.rs @@ -64,7 +64,7 @@ pub fn cal_contract_address( // future. buffer[0] = 0x0; buffer[1..(1 + 20)].copy_from_slice(&sender[..]); - nonce.to_little_endian(&mut buffer[(1 + 20)..(1 + 20 + 32)]); + nonce.write_as_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 diff --git a/crates/cfx_types/src/utils.rs b/crates/cfx_types/src/utils.rs index 6391b144c3..3486720c1a 100644 --- a/crates/cfx_types/src/utils.rs +++ b/crates/cfx_types/src/utils.rs @@ -35,7 +35,7 @@ pub fn parse_hex_string(hex_str: &str) -> Result { pub fn u256_to_h256_be(value: U256) -> H256 { let mut buf = [0u8; 32]; - value.to_big_endian(&mut buf); + value.write_as_big_endian(&mut buf); H256::from(buf) } diff --git a/crates/cfxcore/core/Cargo.toml b/crates/cfxcore/core/Cargo.toml index 22bc04b991..6ab8cb834a 100644 --- a/crates/cfxcore/core/Cargo.toml +++ b/crates/cfxcore/core/Cargo.toml @@ -54,6 +54,7 @@ rangetools = { workspace = true } rayon = { workspace = true } rlp = { workspace = true } rlp_derive = { workspace = true } +bytes = { workspace = true } rustc-hex = { workspace = true } secret-store = { workspace = true } serde = { workspace = true, features = ["rc"] } @@ -117,6 +118,7 @@ cfx-rpc-utils = { workspace = true } cfx-util-macros = { workspace = true } cfxcore-types = { workspace = true } cfxcore-pow = { workspace = true } +rlp-bool = { workspace = true } [dev-dependencies] cfx-storage = { workspace = true, features = ["testonly_code"] } @@ -135,4 +137,4 @@ consensus_bench = [] fuzzing = ["proptest", "proptest-derive"] [lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mirai)'] } \ No newline at end of file +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mirai)'] } diff --git a/crates/cfxcore/core/examples/snapshot_merge_test.rs b/crates/cfxcore/core/examples/snapshot_merge_test.rs index f5c483859e..58736aa7fc 100644 --- a/crates/cfxcore/core/examples/snapshot_merge_test.rs +++ b/crates/cfxcore/core/examples/snapshot_merge_test.rs @@ -28,6 +28,7 @@ use std::{ str::FromStr, sync::Arc, time::Instant, }; +use rlp_bool::CompatibleBool; // cargo run --release -p cfxcore --example snapshot_merge_test // cargo run --release -p cfxcore --example snapshot_merge_test -- --help fn main() -> Result<(), Error> { @@ -92,7 +93,7 @@ fn main() -> Result<(), Error> { merkle_root: Default::default(), parent_snapshot_epoch_id: NULL_EPOCH, pivot_chain_parts: vec![snapshot1_epoch], - serve_one_step_sync: false, + serve_one_step_sync: CompatibleBool(false), snapshot_info_kept_to_provide_sync: Default::default(), }; let (mut snapshot_info_map_locked, snapshot_info1) = snapshot_db_manager @@ -163,7 +164,7 @@ fn main() -> Result<(), Error> { merkle_root: snapshot_info1.merkle_root, parent_snapshot_epoch_id: snapshot1_epoch, pivot_chain_parts: vec![snapshot2_epoch], - serve_one_step_sync: false, + serve_one_step_sync: CompatibleBool(false), snapshot_info_kept_to_provide_sync: Default::default(), }; let (mut snapshot_info_map_locked, snapshot_info2) = snapshot_db_manager @@ -198,7 +199,7 @@ fn main() -> Result<(), Error> { assert!(value.is_some(), "Address {:?} does not exist", addr); let account_bytes = rlp::encode(account); let get_bytes = value.unwrap(); - assert_eq!(account_bytes.as_slice(), get_bytes.as_ref()); + assert_eq!(account_bytes.as_ref(), get_bytes.as_ref()); } // TODO Make snapshot3 to compare the snapshot merkle_root let state_root_3 = StateRootWithAuxInfo::genesis(&MERKLE_NULL_NODE); @@ -230,7 +231,7 @@ fn main() -> Result<(), Error> { merkle_root: Default::default(), parent_snapshot_epoch_id: NULL_EPOCH, pivot_chain_parts: vec![snapshot3_epoch], - serve_one_step_sync: false, + serve_one_step_sync: CompatibleBool(false), snapshot_info_kept_to_provide_sync: Default::default(), }; let (mut snapshot_info_map_locked, snapshot_info3) = snapshot_db_manager diff --git a/crates/cfxcore/core/src/block_data_manager/mod.rs b/crates/cfxcore/core/src/block_data_manager/mod.rs index 3e8917abfd..477f9bb688 100644 --- a/crates/cfxcore/core/src/block_data_manager/mod.rs +++ b/crates/cfxcore/core/src/block_data_manager/mod.rs @@ -51,6 +51,7 @@ use cfx_internal_common::{ use db_gc_manager::GCProgress; use metrics::{register_meter_with_group, Meter, MeterTimer}; use primitives::pos::PosBlockId; +use rlp_bool::CompatibleBool; use std::{hash::Hash, path::Path, time::Duration}; lazy_static! { @@ -272,7 +273,7 @@ impl BlockDataManager { &TransactionIndex { block_hash: cur_era_genesis_hash, real_index: index, - is_phantom: false, + is_phantom: CompatibleBool(false), // FIXME(thegaram): do we allow EVM txs in genesis? rpc_index: Some(index), }, @@ -1304,7 +1305,7 @@ impl BlockDataManager { &TransactionIndex { block_hash: *block_hash, real_index: tx_idx, - is_phantom: false, + is_phantom: CompatibleBool(false), rpc_index: Some(rpc_index), }, ); @@ -1315,7 +1316,7 @@ impl BlockDataManager { &TransactionIndex { block_hash: *block_hash, real_index: tx_idx, - is_phantom: true, + is_phantom: CompatibleBool(true), rpc_index: Some(evm_tx_index), }, ); diff --git a/crates/cfxcore/core/src/consensus/consensus_graph/rpc_api/trace_provider.rs b/crates/cfxcore/core/src/consensus/consensus_graph/rpc_api/trace_provider.rs index da1610f06e..ee2fc9a25a 100644 --- a/crates/cfxcore/core/src/consensus/consensus_graph/rpc_api/trace_provider.rs +++ b/crates/cfxcore/core/src/consensus/consensus_graph/rpc_api/trace_provider.rs @@ -940,7 +940,7 @@ impl ConsensusGraph { } let trace = LocalizedTrace { action: trace.action, - valid: trace.valid, + valid: trace.valid.into(), epoch_hash: pivot_hash, epoch_number: epoch_number.into(), block_hash, diff --git a/crates/cfxcore/core/src/consensus/consensus_inner/consensus_executor/epoch_execution.rs b/crates/cfxcore/core/src/consensus/consensus_inner/consensus_executor/epoch_execution.rs index a327d12fca..08ff8676bc 100644 --- a/crates/cfxcore/core/src/consensus/consensus_inner/consensus_executor/epoch_execution.rs +++ b/crates/cfxcore/core/src/consensus/consensus_inner/consensus_executor/epoch_execution.rs @@ -33,7 +33,7 @@ use cfx_executor::{ }, }; use cfx_vm_types::Env; - +use rlp_bool::CompatibleBool; pub enum VirtualCall<'a> { GethTrace(GethTask<'a>), } @@ -329,7 +329,7 @@ impl ConsensusExecutionHandler { &TransactionIndex { block_hash: block.hash(), real_index: idx, - is_phantom: false, + is_phantom: CompatibleBool(false), rpc_index: Some(rpc_index), }, ); @@ -349,7 +349,7 @@ impl ConsensusExecutionHandler { &TransactionIndex { block_hash: block.hash(), real_index: idx, - is_phantom: true, + is_phantom: CompatibleBool(true), rpc_index: Some(*evm_tx_index), }, ); diff --git a/crates/cfxcore/core/src/light_protocol/handler/sync/tx_infos.rs b/crates/cfxcore/core/src/light_protocol/handler/sync/tx_infos.rs index 8753edadad..5e48dea3ea 100644 --- a/crates/cfxcore/core/src/light_protocol/handler/sync/tx_infos.rs +++ b/crates/cfxcore/core/src/light_protocol/handler/sync/tx_infos.rs @@ -31,6 +31,7 @@ use parking_lot::RwLock; use primitives::{ Receipt, SignedTransaction, TransactionIndex, TransactionStatus, }; +use rlp_bool::CompatibleBool; use std::{future::Future, sync::Arc}; #[derive(Debug)] @@ -357,7 +358,7 @@ impl TxInfos { let tx_index = TransactionIndex { block_hash, real_index: tx_index_in_block, - is_phantom: false, + is_phantom: CompatibleBool(false), rpc_index: None, }; diff --git a/crates/cfxcore/core/src/light_protocol/provider.rs b/crates/cfxcore/core/src/light_protocol/provider.rs index 818411217d..18bca29559 100644 --- a/crates/cfxcore/core/src/light_protocol/provider.rs +++ b/crates/cfxcore/core/src/light_protocol/provider.rs @@ -59,6 +59,7 @@ use primitives::{ }; use rand::prelude::SliceRandom; use rlp::Rlp; +use rlp_bool::CompatibleBool; use std::{ sync::{Arc, Weak}, time::{Duration, Instant}, @@ -248,7 +249,8 @@ impl Provider { TransactionInfo { tx_index: TransactionIndex { - is_phantom: true, .. + is_phantom: CompatibleBool(true), + .. }, .. }, diff --git a/crates/cfxcore/core/src/message.rs b/crates/cfxcore/core/src/message.rs index 788ffc43d5..2a10217c2d 100644 --- a/crates/cfxcore/core/src/message.rs +++ b/crates/cfxcore/core/src/message.rs @@ -6,6 +6,7 @@ pub type RequestId = u64; pub type MsgId = u16; const MSG_ID_MAX: u16 = 1 << 14; +use bytes::{BufMut, BytesMut}; pub use cfx_bytes::Bytes; pub use priority_send_queue::SendQueuePriority; use rlp::{Decodable, Rlp}; @@ -60,16 +61,16 @@ pub trait Message: // If true, message may be throttled when sent to remote peer. fn is_size_sensitive(&self) -> bool { false } fn msg_id(&self) -> MsgId; - fn push_msg_id_leb128_encoding(&self, buffer: &mut Vec) { + fn push_msg_id_leb128_encoding(&self, buffer: &mut BytesMut) { let msg_id = self.msg_id(); assert!(msg_id < MSG_ID_MAX); let msg_id_msb = (msg_id >> 7) as u8; let mut msg_id_lsb = (msg_id as u8) & 0x7f; if msg_id_msb != 0 { - buffer.push(msg_id_msb); + buffer.put_u8(msg_id_msb); msg_id_lsb |= 0x80; } - buffer.push(msg_id_lsb); + buffer.put_u8(msg_id_lsb); } fn msg_name(&self) -> &'static str; fn priority(&self) -> SendQueuePriority { SendQueuePriority::High } @@ -187,7 +188,7 @@ macro_rules! build_msg_basic { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } }; @@ -278,10 +279,10 @@ mod test { #[test] fn test_message_id_encode_decode() { for msg_id in 0..MSG_ID_MAX { - let mut buf = vec![]; let message = TestMessage { msg_id }; - buf.extend_from_slice(&message.rlp_bytes()); - message.push_msg_id_leb128_encoding(&mut buf); + let mut encoded = message.rlp_bytes(); + message.push_msg_id_leb128_encoding(&mut encoded); + let buf = encoded.as_ref(); match decode_msg(&buf) { None => assert!(false, "Can not decode message"), Some((decoded_msg_id, rlp)) => { diff --git a/crates/cfxcore/core/src/pos/consensus/liveness/vrf_proposer_election.rs b/crates/cfxcore/core/src/pos/consensus/liveness/vrf_proposer_election.rs index 97e9472a9f..17f62b0114 100644 --- a/crates/cfxcore/core/src/pos/consensus/liveness/vrf_proposer_election.rs +++ b/crates/cfxcore/core/src/pos/consensus/liveness/vrf_proposer_election.rs @@ -39,7 +39,7 @@ impl VrfProposer { proposal_threshold_u256: U256, epoch_state: EpochState, ) -> Self { let mut proposal_threshold = [0 as u8; HashValue::LENGTH]; - proposal_threshold_u256.to_big_endian(&mut proposal_threshold); + proposal_threshold_u256.write_as_big_endian(&mut proposal_threshold); Self { author, vrf_private_key, diff --git a/crates/cfxcore/core/src/sync/message/capability.rs b/crates/cfxcore/core/src/sync/message/capability.rs index 2e4fe9ed48..5f8f68023d 100644 --- a/crates/cfxcore/core/src/sync/message/capability.rs +++ b/crates/cfxcore/core/src/sync/message/capability.rs @@ -12,11 +12,12 @@ use crate::{ use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf; use network::{node_table::NodeId, NetworkContext}; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; +use rlp_bool::CompatibleBool; #[derive(Debug, Eq, PartialEq, Clone, Copy, DeriveMallocSizeOf)] pub enum DynamicCapability { - NormalPhase(bool), // provide tx relay - ServeHeaders(bool), // provide block header downloads + NormalPhase(CompatibleBool), // provide tx relay + ServeHeaders(CompatibleBool), // provide block header downloads } impl DynamicCapability { diff --git a/crates/cfxcore/core/src/sync/message/get_block_txn.rs b/crates/cfxcore/core/src/sync/message/get_block_txn.rs index b0f816aee7..88ea7fe056 100644 --- a/crates/cfxcore/core/src/sync/message/get_block_txn.rs +++ b/crates/cfxcore/core/src/sync/message/get_block_txn.rs @@ -15,9 +15,9 @@ use crate::{ }; use cfx_types::H256; use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf; +use rlp_bool::CompatibleBool; use rlp_derive::{RlpDecodable, RlpEncodable}; use std::{any::Any, time::Duration}; - #[derive( Debug, PartialEq, @@ -63,7 +63,7 @@ impl Request for GetBlockTxn { request_id: 0, // request_block_need_public can only be true in catch_up_mode, // where GetBlockTxn can not be initiated. - with_public: false, + with_public: CompatibleBool(false), hashes: vec![self.block_hash.clone()], preferred_node_type: None, })) diff --git a/crates/cfxcore/core/src/sync/message/get_blocks.rs b/crates/cfxcore/core/src/sync/message/get_blocks.rs index 023eedb98a..3a9e438eab 100644 --- a/crates/cfxcore/core/src/sync/message/get_blocks.rs +++ b/crates/cfxcore/core/src/sync/message/get_blocks.rs @@ -19,12 +19,12 @@ use cfx_types::H256; use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf; use primitives::Block; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; +use rlp_bool::CompatibleBool; use std::{any::Any, time::Duration}; - #[derive(Debug, PartialEq, Default, Clone, DeriveMallocSizeOf)] pub struct GetBlocks { pub request_id: RequestId, - pub with_public: bool, + pub with_public: CompatibleBool, pub hashes: Vec, // This field specifies what node type of peers this // request needs to be sent to. @@ -167,8 +167,8 @@ impl GetBlocks { impl Handleable for GetBlocks { fn handle(self, ctx: &Context) -> Result<(), Error> { - let blocks = self.get_blocks(ctx, self.with_public); - if self.with_public { + let blocks = self.get_blocks(ctx, self.with_public.into()); + if self.with_public.into() { self.send_response_with_public(ctx, blocks) } else { self.send_response(ctx, blocks) diff --git a/crates/cfxcore/core/src/sync/message/get_compact_blocks.rs b/crates/cfxcore/core/src/sync/message/get_compact_blocks.rs index d63552df4c..52ae6b5b97 100644 --- a/crates/cfxcore/core/src/sync/message/get_compact_blocks.rs +++ b/crates/cfxcore/core/src/sync/message/get_compact_blocks.rs @@ -16,9 +16,9 @@ use crate::{ use cfx_parameters::sync::{MAX_BLOCKS_TO_SEND, MAX_HEADERS_TO_SEND}; use cfx_types::H256; use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf; +use rlp_bool::CompatibleBool; use rlp_derive::{RlpDecodable, RlpEncodable}; use std::{any::Any, time::Duration}; - #[derive( Debug, PartialEq, Default, RlpDecodable, RlpEncodable, DeriveMallocSizeOf, )] @@ -58,7 +58,7 @@ impl Request for GetCompactBlocks { fn resend(&self) -> Option> { Some(Box::new(GetBlocks { request_id: 0, - with_public: true, + with_public: CompatibleBool(true), hashes: self.hashes.iter().cloned().collect(), preferred_node_type: None, })) diff --git a/crates/cfxcore/core/src/sync/message/message.rs b/crates/cfxcore/core/src/sync/message/message.rs index 59c57a815b..ada7bb0378 100644 --- a/crates/cfxcore/core/src/sync/message/message.rs +++ b/crates/cfxcore/core/src/sync/message/message.rs @@ -97,7 +97,7 @@ impl Message for GetBlockHashesResponse { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } @@ -114,7 +114,7 @@ impl Message for Transactions { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } @@ -130,7 +130,7 @@ impl Message for GetBlocksResponse { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } @@ -150,7 +150,7 @@ impl Message for GetBlocksWithPublicResponse { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } @@ -166,7 +166,7 @@ impl Message for GetBlockTxnResponse { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } @@ -184,7 +184,7 @@ impl Message for TransactionDigests { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } @@ -202,7 +202,7 @@ impl Message for GetTransactionsResponse { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } impl GetMaybeRequestId for GetTransactionsFromTxHashesResponse {} @@ -225,7 +225,7 @@ impl Message for GetTransactionsFromTxHashesResponse { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } /// handle the RLP encoded message with given context `ctx`. diff --git a/crates/cfxcore/core/src/sync/message/status.rs b/crates/cfxcore/core/src/sync/message/status.rs index 2f98929ba6..cae7cabd1d 100644 --- a/crates/cfxcore/core/src/sync/message/status.rs +++ b/crates/cfxcore/core/src/sync/message/status.rs @@ -15,6 +15,7 @@ use crate::{ use cfx_internal_common::ChainIdParamsDeprecated; use cfx_types::H256; use network::{NODE_TAG_ARCHIVE, NODE_TAG_FULL, NODE_TAG_NODE_TYPE}; +use rlp_bool::CompatibleBool; use rlp_derive::{RlpDecodable, RlpEncodable}; use std::{collections::HashSet, time::Instant}; use throttling::token_bucket::TokenBucketManager; @@ -111,7 +112,7 @@ impl Handleable for StatusV2 { peer_state .capabilities - .insert(DynamicCapability::NormalPhase(true)); + .insert(DynamicCapability::NormalPhase(CompatibleBool(true))); debug!( "New peer (pv={:?}, gh={:?})", @@ -238,7 +239,7 @@ impl Handleable for StatusV3 { peer_state .capabilities - .insert(DynamicCapability::NormalPhase(true)); + .insert(DynamicCapability::NormalPhase(CompatibleBool(true))); debug!( "New peer (pv={:?}, gh={:?})", diff --git a/crates/cfxcore/core/src/sync/message/transactions.rs b/crates/cfxcore/core/src/sync/message/transactions.rs index d7a32a5886..d57bd96318 100644 --- a/crates/cfxcore/core/src/sync/message/transactions.rs +++ b/crates/cfxcore/core/src/sync/message/transactions.rs @@ -23,10 +23,10 @@ use network::service::ProtocolVersion; use primitives::{transaction::TxPropagateId, TransactionWithSignature}; use priority_send_queue::SendQueuePriority; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; +use rlp_bool::CompatibleBool; use rlp_derive::{RlpDecodable, RlpEncodable}; use siphasher::sip::SipHasher24; use std::{any::Any, collections::HashSet, hash::Hasher, time::Duration}; - #[derive(Debug, PartialEq)] pub struct Transactions { pub transactions: Vec, @@ -59,7 +59,7 @@ impl Handleable for Transactions { let mut peer_info = peer_info.write(); if peer_info .notified_capabilities - .contains(DynamicCapability::NormalPhase(false)) + .contains(DynamicCapability::NormalPhase(CompatibleBool(false))) { peer_info.received_transaction_count += transactions.len(); peer_info.received_transaction_count @@ -132,7 +132,7 @@ impl Handleable for TransactionDigests { let mut peer_info = peer_info.write(); if peer_info .notified_capabilities - .contains(DynamicCapability::NormalPhase(false)) + .contains(DynamicCapability::NormalPhase(CompatibleBool(false))) { peer_info.received_transaction_count += self.short_ids.len() / Self::SHORT_ID_SIZE_IN_BYTES @@ -315,7 +315,7 @@ impl Message for GetTransactions { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } @@ -474,7 +474,7 @@ impl Message for GetTransactionsFromTxHashes { fn encode(&self) -> Vec { let mut encoded = self.rlp_bytes(); self.push_msg_id_leb128_encoding(&mut encoded); - encoded + encoded.into() } } diff --git a/crates/cfxcore/core/src/sync/request_manager/mod.rs b/crates/cfxcore/core/src/sync/request_manager/mod.rs index fd210c0077..f8975af58b 100644 --- a/crates/cfxcore/core/src/sync/request_manager/mod.rs +++ b/crates/cfxcore/core/src/sync/request_manager/mod.rs @@ -33,6 +33,7 @@ use primitives::{SignedTransaction, TransactionWithSignature}; pub use request_handler::{ AsAny, Request, RequestHandler, RequestMessage, SynchronizationPeerRequest, }; +use rlp_bool::CompatibleBool; use std::{ cmp::Ordering, collections::{binary_heap::BinaryHeap, HashSet}, @@ -298,7 +299,7 @@ impl RequestManager { let request = GetBlocks { request_id: 0, - with_public, + with_public: CompatibleBool(with_public), hashes, preferred_node_type, }; diff --git a/crates/cfxcore/core/src/sync/request_manager/request_batcher.rs b/crates/cfxcore/core/src/sync/request_manager/request_batcher.rs index 51ff2bea48..7ddbd55644 100644 --- a/crates/cfxcore/core/src/sync/request_manager/request_batcher.rs +++ b/crates/cfxcore/core/src/sync/request_manager/request_batcher.rs @@ -6,6 +6,7 @@ use crate::{ NodeType, }; use cfx_types::H256; +use rlp_bool::CompatibleBool; use std::{cmp::min, time::Duration}; const DEFAULT_REQUEST_BATCHER_BUCKET_NUMBER: usize = 30; @@ -100,7 +101,7 @@ impl RequestBatcher { delay, Box::new(GetBlocks { request_id: 0, - with_public: false, + with_public: CompatibleBool(false), hashes, preferred_node_type: preferred_node_type.clone(), }) as Box, diff --git a/crates/cfxcore/core/src/sync/state/state_sync_manifest/snapshot_manifest_manager.rs b/crates/cfxcore/core/src/sync/state/state_sync_manifest/snapshot_manifest_manager.rs index 20f5318be2..5cfd0cf71b 100644 --- a/crates/cfxcore/core/src/sync/state/state_sync_manifest/snapshot_manifest_manager.rs +++ b/crates/cfxcore/core/src/sync/state/state_sync_manifest/snapshot_manifest_manager.rs @@ -34,6 +34,7 @@ use rand::{ seq::{IndexedRandom, SliceRandom}, }; +use rlp_bool::CompatibleBool; use std::{ collections::HashSet, fmt::{Debug, Formatter}, @@ -472,7 +473,7 @@ impl SnapshotManifestManager { // Prevent immediate removed by setting 'InfoOnly' to avoid snapshot_info_kept_to_provide_sync: SnapshotKeptToProvideSyncStatus::InfoOnly, - serve_one_step_sync: false, + serve_one_step_sync: CompatibleBool(false), merkle_root: state_root_vec[offset - 1].snapshot_root, height: snapshot_block_header.height() - snapshot_epoch_count as u64, @@ -505,7 +506,7 @@ impl SnapshotManifestManager { }, SnapshotInfo { snapshot_info_kept_to_provide_sync: Default::default(), - serve_one_step_sync: false, + serve_one_step_sync: CompatibleBool(false), // We need the extra -1 to get a state root that points to the // snapshot we want. merkle_root: state_root_vec[offset diff --git a/crates/cfxcore/core/src/sync/synchronization_phases.rs b/crates/cfxcore/core/src/sync/synchronization_phases.rs index 6bfbf2bbab..94dcee14a1 100644 --- a/crates/cfxcore/core/src/sync/synchronization_phases.rs +++ b/crates/cfxcore/core/src/sync/synchronization_phases.rs @@ -16,6 +16,7 @@ use cfx_internal_common::StateAvailabilityBoundary; use cfx_parameters::sync::CATCH_UP_EPOCH_LAG_THRESHOLD; use network::NetworkContext; use parking_lot::RwLock; +use rlp_bool::CompatibleBool; use std::{ collections::HashMap, sync::{ @@ -25,7 +26,6 @@ use std::{ thread, time::{self, Instant}, }; - /// Both Archive and Full node go through the following phases: /// CatchUpRecoverBlockHeaderFromDB --> CatchUpSyncBlockHeader --> /// CatchUpCheckpoint --> CatchUpFillBlockBody --> @@ -203,7 +203,8 @@ impl SynchronizationPhaseTrait for CatchUpRecoverBlockHeaderFromDbPhase { return self.phase_type(); } - DynamicCapability::ServeHeaders(true).broadcast(io, &sync_handler.syn); + DynamicCapability::ServeHeaders(CompatibleBool(true)) + .broadcast(io, &sync_handler.syn); SyncPhaseType::CatchUpSyncBlockHeader } diff --git a/crates/cfxcore/core/src/sync/synchronization_protocol_handler.rs b/crates/cfxcore/core/src/sync/synchronization_protocol_handler.rs index 3d7062e17f..e25eed1879 100644 --- a/crates/cfxcore/core/src/sync/synchronization_protocol_handler.rs +++ b/crates/cfxcore/core/src/sync/synchronization_protocol_handler.rs @@ -43,13 +43,13 @@ use parking_lot::{Mutex, RwLock}; use primitives::{Block, BlockHeader, EpochId, SignedTransaction}; use rand::{prelude::SliceRandom, Rng}; use rlp::Rlp; +use rlp_bool::CompatibleBool; use std::{ cmp::{self, min}, collections::{BTreeMap, HashMap, HashSet, VecDeque}, sync::Arc, time::{Duration, Instant, SystemTime, UNIX_EPOCH}, }; - lazy_static! { static ref TX_PROPAGATE_METER: Arc = register_meter_with_group("system_metrics", "tx_propagate_set_size"); @@ -1339,7 +1339,7 @@ impl SynchronizationProtocolHandler { .min(self.protocol_config.max_peers_tx_propagation); PeerFilter::new(msgid::TRANSACTION_DIGESTS) - .with_cap(DynamicCapability::NormalPhase(true)) + .with_cap(DynamicCapability::NormalPhase(CompatibleBool(true))) .select_n(num_peers, &self.syn) } @@ -1637,14 +1637,15 @@ impl SynchronizationProtocolHandler { let mut need_notify = Vec::new(); for (peer, state) in self.syn.peers.read().iter() { let mut state = state.write(); - if !state - .notified_capabilities - .contains(DynamicCapability::NormalPhase(!catch_up_mode)) - { + if !state.notified_capabilities.contains( + DynamicCapability::NormalPhase(CompatibleBool(!catch_up_mode)), + ) { state.received_transaction_count = 0; - state - .notified_capabilities - .insert(DynamicCapability::NormalPhase(!catch_up_mode)); + state.notified_capabilities.insert( + DynamicCapability::NormalPhase(CompatibleBool( + !catch_up_mode, + )), + ); need_notify.push(*peer); } } @@ -1655,7 +1656,7 @@ impl SynchronizationProtocolHandler { self.graph.inner.read().block_to_fill_set.len() ); - DynamicCapability::NormalPhase(!catch_up_mode) + DynamicCapability::NormalPhase(CompatibleBool(!catch_up_mode)) .broadcast_with_peers(io, need_notify); } diff --git a/crates/cfxcore/core/src/sync/synchronization_state.rs b/crates/cfxcore/core/src/sync/synchronization_state.rs index 043be84b3e..d5f64f1c00 100644 --- a/crates/cfxcore/core/src/sync/synchronization_state.rs +++ b/crates/cfxcore/core/src/sync/synchronization_state.rs @@ -18,13 +18,13 @@ use network::{ }; use parking_lot::RwLock; use rand::prelude::{IndexedRandom, SliceRandom}; +use rlp_bool::CompatibleBool; use std::{ collections::{HashMap, HashSet}, sync::Arc, time::{Duration, Instant}, }; use throttling::token_bucket::{ThrottledManager, TokenBucketManager}; - #[derive(DeriveMallocSizeOf)] pub struct SynchronizationPeerState { pub node_id: NodeId, @@ -220,10 +220,9 @@ impl SynchronizationState { } for (_, state_lock) in &*peers { let state = state_lock.read(); - if state - .capabilities - .contains(DynamicCapability::NormalPhase(true)) - { + if state.capabilities.contains(DynamicCapability::NormalPhase( + CompatibleBool(true), + )) { fresh_start = false; peer_best_epoches.push(state.best_epoch); } else if state.best_epoch != 0 { diff --git a/crates/cfxcore/core/src/verification.rs b/crates/cfxcore/core/src/verification.rs index 02b500c9b3..685174977b 100644 --- a/crates/cfxcore/core/src/verification.rs +++ b/crates/cfxcore/core/src/verification.rs @@ -84,7 +84,10 @@ fn block_receipts_trie(block_receipts: &Vec) -> SimpleMpt { make_simple_mpt( block_receipts .iter() - .map(|receipt| receipt.rlp_bytes().into_boxed_slice()) + .map(|receipt| { + let vec_u8: Vec = receipt.rlp_bytes().into(); + vec_u8.into_boxed_slice() + }) .collect(), ) } diff --git a/crates/cfxcore/internal_common/src/block_data_db_encoding.rs b/crates/cfxcore/internal_common/src/block_data_db_encoding.rs index 1bc1b22342..a7bf49e62d 100644 --- a/crates/cfxcore/internal_common/src/block_data_db_encoding.rs +++ b/crates/cfxcore/internal_common/src/block_data_db_encoding.rs @@ -14,7 +14,7 @@ pub trait DatabaseDecodable: Sized { macro_rules! impl_db_encoding_as_rlp { ($type:ty) => { impl $crate::DatabaseEncodable for $type { - fn db_encode(&self) -> Vec { rlp::encode(self) } + fn db_encode(&self) -> Vec { rlp::encode(self).to_vec() } } impl $crate::DatabaseDecodable for $type { @@ -39,7 +39,7 @@ impl DatabaseEncodable for BlockHeader { fn db_encode(&self) -> Bytes { let mut rlp_stream = RlpStream::new(); self.stream_rlp_with_pow_hash(&mut rlp_stream); - rlp_stream.drain() + rlp_stream.as_raw().into() } } diff --git a/crates/cfxcore/pow/src/lib.rs b/crates/cfxcore/pow/src/lib.rs index 8d0ff0a728..96e69a2a6f 100644 --- a/crates/cfxcore/pow/src/lib.rs +++ b/crates/cfxcore/pow/src/lib.rs @@ -214,13 +214,13 @@ impl ProofOfWorkConfig { // withholding attack among mining pools. pub fn nonce_to_lower_bound(nonce: &U256) -> U256 { let mut buf = [0u8; 32]; - nonce.to_big_endian(&mut buf[..]); + nonce.write_as_big_endian(&mut buf[..]); for i in 16..32 { buf[i] = 0; } buf[0] = buf[0] & 0x7f; // Note that U256::from assumes big_endian of the bytes - let lower_bound = U256::from(buf); + let lower_bound = U256::from_big_endian(buf.as_ref()); lower_bound } @@ -301,7 +301,7 @@ impl PowComputer { for i in 0..32 { buf[i] = block_hash[i]; } - nonce.to_little_endian(&mut buf[32..64]); + nonce.write_as_little_endian(&mut buf[32..64]); let intermediate = keccak_hash(&buf[..]); let mut tmp = [0u8; 32]; for i in 0..32 { diff --git a/crates/cfxcore/types/src/block_data_manager/block_data_types.rs b/crates/cfxcore/types/src/block_data_manager/block_data_types.rs index 4b1cf6b2e9..7847937b72 100644 --- a/crates/cfxcore/types/src/block_data_manager/block_data_types.rs +++ b/crates/cfxcore/types/src/block_data_manager/block_data_types.rs @@ -199,7 +199,7 @@ impl Decodable impl DatabaseEncodable for DataVersionTuple { - fn db_encode(&self) -> Vec { rlp::encode(self) } + fn db_encode(&self) -> Vec { rlp::encode(self).into() } } impl DatabaseDecodable @@ -370,7 +370,7 @@ where T: DatabaseEncodable { for e in list { rlp_stream.append_raw(&e.db_encode(), 1); } - rlp_stream.drain() + rlp_stream.as_raw().into() } pub fn db_decode_list(bytes: &[u8]) -> Result, DecoderError> diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 87e03cdd28..1ac57ae739 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -79,6 +79,7 @@ cfx-parity-trace-types = { workspace = true } cfx-tasks = { workspace = true } cfx-config = { workspace = true } cfxcore-types = { workspace = true } +rlp-bool = { workspace = true } [dev-dependencies] criterion = { workspace = true } diff --git a/crates/client/src/rpc/helpers/block_provider.rs b/crates/client/src/rpc/helpers/block_provider.rs index 482b089179..8654bcb8a0 100644 --- a/crates/client/src/rpc/helpers/block_provider.rs +++ b/crates/client/src/rpc/helpers/block_provider.rs @@ -17,8 +17,8 @@ use primitives::{ Block as PrimitiveBlock, BlockHeader as PrimitiveBlockHeader, TransactionIndex, TransactionStatus, }; +use rlp_bool::CompatibleBool; use std::sync::Arc; - pub fn build_block( b: &PrimitiveBlock, network: Network, consensus: &ConsensusGraph, consensus_inner: &ConsensusGraphInner, data_man: &Arc, @@ -109,7 +109,7 @@ pub fn build_block( let tx_index = TransactionIndex { block_hash: b.hash(), real_index: original_index, - is_phantom: false, + is_phantom: CompatibleBool(false), rpc_index: Some(new_index), }; let tx_exec_error_msg = diff --git a/crates/client/src/rpc/impls/cfx/cfx_handler.rs b/crates/client/src/rpc/impls/cfx/cfx_handler.rs index 4a3f6a5fe6..42ccb7cbf8 100644 --- a/crates/client/src/rpc/impls/cfx/cfx_handler.rs +++ b/crates/client/src/rpc/impls/cfx/cfx_handler.rs @@ -113,6 +113,7 @@ use cfxcore::{ consensus_parameters::DEFERRED_STATE_EPOCH_COUNT, }; use diem_types::account_address::AccountAddress; +use rlp_bool::CompatibleBool; use serde::Serialize; #[derive(Debug)] @@ -710,7 +711,7 @@ impl RpcImpl { }, )) = self.consensus.get_transaction_info_by_hash(&hash) { - if tx.space() == Space::Ethereum || tx_index.is_phantom { + if tx.space() == Space::Ethereum || tx_index.is_phantom.into() { return Ok(None); } @@ -853,7 +854,7 @@ impl RpcImpl { let tx = &exec_info.block.transactions[id]; if !include_eth_receipt - && (tx.space() == Space::Ethereum || tx_index.is_phantom) + && (tx.space() == Space::Ethereum || tx_index.is_phantom.into()) { return Ok(None); } @@ -904,7 +905,7 @@ impl RpcImpl { Some(tx_index) => tx_index, }; - if tx_index.is_phantom { + if tx_index.is_phantom.into() { return Ok(None); } @@ -966,7 +967,7 @@ impl RpcImpl { TransactionIndex { block_hash, real_index: original_index, - is_phantom: false, + is_phantom: CompatibleBool(false), rpc_index: Some(new_index), }, &exec_info, @@ -2220,7 +2221,7 @@ impl RpcImpl { let tx_index = TransactionIndex { block_hash: b.hash(), real_index: id, - is_phantom: false, + is_phantom: CompatibleBool(false), rpc_index: Some(cfx_transaction_index), }; let tx_exec_error_msg = &execution_result diff --git a/crates/client/src/rpc/impls/cfx/common.rs b/crates/client/src/rpc/impls/cfx/common.rs index 7a869d070e..50ddcd6acf 100644 --- a/crates/client/src/rpc/impls/cfx/common.rs +++ b/crates/client/src/rpc/impls/cfx/common.rs @@ -354,7 +354,7 @@ impl RpcImpl { .expect("failed to convert scaled risk to bigInt"); let (sign, big_endian_bytes) = scaled_risk.to_bytes_be(); assert_ne!(sign, num_bigint::Sign::Minus); - let rpc_result = U256::from(big_endian_bytes.as_slice()); + let rpc_result = U256::from_big_endian(big_endian_bytes.as_slice()); Ok(Some(rpc_result.into())) } } diff --git a/crates/client/src/rpc/impls/cfx/light.rs b/crates/client/src/rpc/impls/cfx/light.rs index 0a36ad2995..593b9814ae 100644 --- a/crates/client/src/rpc/impls/cfx/light.rs +++ b/crates/client/src/rpc/impls/cfx/light.rs @@ -562,7 +562,7 @@ impl RpcImpl { accounts, )?; - Self::send_tx_helper(light, Bytes::new(tx.rlp_bytes())) + Self::send_tx_helper(light, Bytes::new(tx.rlp_bytes().into())) }; fut.boxed() @@ -698,7 +698,7 @@ impl RpcImpl { prior_gas_used, } = tx_info; - if maybe_block_number.is_none() || tx_index.is_phantom { + if maybe_block_number.is_none() || tx_index.is_phantom.into() { return Ok(None); } diff --git a/crates/client/src/rpc/types/cfx/receipt.rs b/crates/client/src/rpc/types/cfx/receipt.rs index b480a37be8..05400b21ae 100644 --- a/crates/client/src/rpc/types/cfx/receipt.rs +++ b/crates/client/src/rpc/types/cfx/receipt.rs @@ -228,8 +228,8 @@ impl Receipt { .map_or_else(Default::default, Into::into), epoch_number: epoch_number.map(U64::from), tx_exec_error_msg, - gas_covered_by_sponsor: gas_sponsor_paid, - storage_covered_by_sponsor: storage_sponsor_paid, + gas_covered_by_sponsor: gas_sponsor_paid.into(), + storage_covered_by_sponsor: storage_sponsor_paid.into(), storage_collateralized, storage_released: storage_released .into_iter() diff --git a/crates/dbs/statedb/src/statedb_ext.rs b/crates/dbs/statedb/src/statedb_ext.rs index 35edf46078..b76d95e5a7 100644 --- a/crates/dbs/statedb/src/statedb_ext.rs +++ b/crates/dbs/statedb/src/statedb_ext.rs @@ -77,11 +77,8 @@ impl StateDbExt for StateDbGeneric { if value.is_default() { self.delete(key, debug_record) } else { - self.set_raw( - key, - ::rlp::encode(value).into_boxed_slice(), - debug_record, - ) + let value_vec = Vec::from(::rlp::encode(value)); + self.set_raw(key, value_vec.into_boxed_slice(), debug_record) } } diff --git a/crates/dbs/storage/Cargo.toml b/crates/dbs/storage/Cargo.toml index 7ccadeb449..f7aef44f73 100644 --- a/crates/dbs/storage/Cargo.toml +++ b/crates/dbs/storage/Cargo.toml @@ -38,6 +38,7 @@ serde = { workspace = true, features = ["rc"] } sqlite = { workspace = true } sqlite3-sys = { workspace = true } strfmt = { workspace = true } +rlp-bool = { workspace = true } tokio = { workspace = true, features = ["sync"] } parity-util-mem = { workspace = true, default-features = false } diff --git a/crates/dbs/storage/src/impls/delta_mpt/cow_node_ref.rs b/crates/dbs/storage/src/impls/delta_mpt/cow_node_ref.rs index 4297c5fe92..fce59ae8b6 100644 --- a/crates/dbs/storage/src/impls/delta_mpt/cow_node_ref.rs +++ b/crates/dbs/storage/src/impls/delta_mpt/cow_node_ref.rs @@ -655,7 +655,7 @@ impl CowNodeRef { .value .try_into() .expect("not exceed i64::MAX"), - trie_node.rlp_bytes().as_slice(), + trie_node.rlp_bytes().as_ref(), )?; commit_transaction.info.row_number = commit_transaction.info.row_number.get_next()?; diff --git a/crates/dbs/storage/src/impls/delta_mpt/tests/children_table.rs b/crates/dbs/storage/src/impls/delta_mpt/tests/children_table.rs index 1b612bf88f..04a42f6dd9 100644 --- a/crates/dbs/storage/src/impls/delta_mpt/tests/children_table.rs +++ b/crates/dbs/storage/src/impls/delta_mpt/tests/children_table.rs @@ -70,7 +70,7 @@ fn test_no_alloc_in_empty_children_table() { let rlp_bytes = empty_children_table.to_ref().rlp_bytes(); let rlp_parsed = - ChildrenTableManagedDeltaMpt::decode(&Rlp::new(rlp_bytes.as_slice())) + ChildrenTableManagedDeltaMpt::decode(&Rlp::new(rlp_bytes.as_ref())) .unwrap(); let decoded_table = ChildrenTableDeltaMpt::from(rlp_parsed); decoded_table.assert_no_alloc_in_empty_children_table(); diff --git a/crates/dbs/storage/src/impls/delta_mpt/tests/rlp_encode_decode.rs b/crates/dbs/storage/src/impls/delta_mpt/tests/rlp_encode_decode.rs index 0905a3abba..6276899c5e 100644 --- a/crates/dbs/storage/src/impls/delta_mpt/tests/rlp_encode_decode.rs +++ b/crates/dbs/storage/src/impls/delta_mpt/tests/rlp_encode_decode.rs @@ -7,8 +7,7 @@ fn test_node_ref_delta_mpt_compact_encode_decode() { let x = NodeRefDeltaMptCompact::new(1234); let rlp_bytes = x.rlp_bytes(); assert_eq!( - NodeRefDeltaMptCompact::decode(&Rlp::new(rlp_bytes.as_slice())) - .unwrap(), + NodeRefDeltaMptCompact::decode(&Rlp::new(rlp_bytes.as_ref())).unwrap(), x ); } @@ -31,7 +30,7 @@ fn test_full_children_table_encode_decode() { } let rlp_bytes = children_table.to_ref().rlp_bytes(); - let rlp = &Rlp::new(rlp_bytes.as_slice()); + let rlp = &Rlp::new(rlp_bytes.as_ref()); // Assert that the rlp has 16 items. assert_eq!(rlp.item_count().unwrap(), 16); @@ -53,7 +52,7 @@ fn test_non_empty_children_table_encode_decode() { } let rlp_bytes = children_table.to_ref().rlp_bytes(); let rlp_parsed = - ChildrenTableManagedDeltaMpt::decode(&Rlp::new(rlp_bytes.as_slice())) + ChildrenTableManagedDeltaMpt::decode(&Rlp::new(rlp_bytes.as_ref())) .unwrap(); assert_eq!(children_table, rlp_parsed.into()); } @@ -63,7 +62,7 @@ fn test_empty_children_table_encode_decode() { let empty_children_table: ChildrenTableDeltaMpt = Default::default(); let rlp_bytes = empty_children_table.to_ref().rlp_bytes(); let rlp_parsed = - ChildrenTableManagedDeltaMpt::decode(&Rlp::new(rlp_bytes.as_slice())) + ChildrenTableManagedDeltaMpt::decode(&Rlp::new(rlp_bytes.as_ref())) .unwrap(); assert_eq!( ChildrenTableDeltaMpt::from(rlp_parsed).get_children_count(), @@ -94,7 +93,7 @@ fn test_trie_node_encode_decode() { ); let rlp_bytes = x.rlp_bytes(); let rlp_parsed = MemOptimizedTrieNode::::decode( - &Rlp::new(rlp_bytes.as_slice()), + &Rlp::new(rlp_bytes.as_ref()), ) .unwrap(); diff --git a/crates/dbs/storage/src/impls/storage_db/snapshot_mpt.rs b/crates/dbs/storage/src/impls/storage_db/snapshot_mpt.rs index 333e0c1778..93bea844d8 100644 --- a/crates/dbs/storage/src/impls/storage_db/snapshot_mpt.rs +++ b/crates/dbs/storage/src/impls/storage_db/snapshot_mpt.rs @@ -178,9 +178,10 @@ impl< &mut self, path: &dyn CompressedPathTrait, trie_node: &SnapshotMptNode, ) -> Result<()> { let key = mpt_node_path_to_db_key(path); + let value_vec = Vec::from(trie_node.rlp_bytes()); self.db .borrow_mut() - .put(&key, &trie_node.rlp_bytes().into_boxed_slice())?; + .put(&key, &value_vec.into_boxed_slice())?; Ok(()) } } diff --git a/crates/dbs/storage/src/impls/storage_manager/storage_manager.rs b/crates/dbs/storage/src/impls/storage_manager/storage_manager.rs index 287df55d37..f9d8365cfb 100644 --- a/crates/dbs/storage/src/impls/storage_manager/storage_manager.rs +++ b/crates/dbs/storage/src/impls/storage_manager/storage_manager.rs @@ -2,6 +2,7 @@ // Conflux is free software and distributed under GNU General Public License. // See http://www.gnu.org/licenses/ +use rlp_bool::CompatibleBool; /// The in mem snapshot_info map and the on disk snapshot_info_db is always in /// sync. pub struct PersistedSnapshotInfoMap { @@ -618,7 +619,7 @@ impl StorageManager { let in_progress_snapshot_info = SnapshotInfo { snapshot_info_kept_to_provide_sync: Default::default(), - serve_one_step_sync: true, + serve_one_step_sync: CompatibleBool(true), height: height as u64, parent_snapshot_height: height - this.storage_conf.consensus_param.snapshot_epoch_count diff --git a/crates/dbs/storage/src/storage_db/snapshot_db.rs b/crates/dbs/storage/src/storage_db/snapshot_db.rs index 50e9295639..eb6ed7b968 100644 --- a/crates/dbs/storage/src/storage_db/snapshot_db.rs +++ b/crates/dbs/storage/src/storage_db/snapshot_db.rs @@ -1,6 +1,7 @@ // 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 rlp_bool::CompatibleBool; #[derive(Clone, Copy, Debug, DeriveMallocSizeOf, PartialEq)] #[repr(u8)] @@ -34,7 +35,7 @@ pub struct SnapshotInfo { /// itself is removed, or when pub snapshot_info_kept_to_provide_sync: SnapshotKeptToProvideSyncStatus, // FIXME: update serve_one_step_sync at maintenance. - pub serve_one_step_sync: bool, + pub serve_one_step_sync: CompatibleBool, pub merkle_root: MerkleHash, pub parent_snapshot_height: u64, @@ -50,7 +51,7 @@ impl SnapshotInfo { pub fn genesis_snapshot_info() -> Self { Self { snapshot_info_kept_to_provide_sync: Default::default(), - serve_one_step_sync: false, + serve_one_step_sync: CompatibleBool(false), merkle_root: MERKLE_NULL_NODE, parent_snapshot_height: 0, height: 0, diff --git a/crates/dbs/storage/src/tests/state.rs b/crates/dbs/storage/src/tests/state.rs index c8390ede05..c00bf3f91d 100644 --- a/crates/dbs/storage/src/tests/state.rs +++ b/crates/dbs/storage/src/tests/state.rs @@ -202,7 +202,7 @@ fn test_snapshot_random_read_performance() { let account_key = StorageKey::new_account_key(&address).with_native_space(); state_0 - .set(account_key, rlp::encode(&account).into()) + .set(account_key, rlp::encode(&account).as_ref().into()) .expect("Failed to set key"); } @@ -381,7 +381,7 @@ fn simulate_transactions( } else { account.balance += U256::one(); } - values[i] = Some(rlp::encode(&account).into()); + values[i] = Some(rlp::encode(&account).as_ref().into()); } *update_ms += now.elapsed().as_millis() as u32; diff --git a/crates/dbs/storage/src/utils/mod.rs b/crates/dbs/storage/src/utils/mod.rs index d87f116c80..e81d432b03 100644 --- a/crates/dbs/storage/src/utils/mod.rs +++ b/crates/dbs/storage/src/utils/mod.rs @@ -102,7 +102,7 @@ pub trait StateRootWithAuxInfoToFromRlpBytes { /// Only used by storage benchmark due to incompatibility of rlp crate version. impl StateRootWithAuxInfoToFromRlpBytes for StateRootWithAuxInfo { - fn to_rlp_bytes(&self) -> Vec { self.rlp_bytes() } + fn to_rlp_bytes(&self) -> Vec { self.rlp_bytes().into() } fn from_rlp_bytes(bytes: &[u8]) -> Result { Ok(Self::decode(&Rlp::new(bytes))?) diff --git a/crates/execution/execute-helper/Cargo.toml b/crates/execution/execute-helper/Cargo.toml index 1df0383681..ff95d84a34 100644 --- a/crates/execution/execute-helper/Cargo.toml +++ b/crates/execution/execute-helper/Cargo.toml @@ -21,6 +21,7 @@ typemap = { workspace = true } alloy-rpc-types-trace = { workspace = true } geth-tracer = { workspace = true } cfx-parity-trace-types = { workspace = true } +rlp-bool = { workspace = true } [features] align_evm = ["cfx-vm-types/align_evm", "cfx-executor/align_evm"] diff --git a/crates/execution/execute-helper/src/observer/exec_tracer/mod.rs b/crates/execution/execute-helper/src/observer/exec_tracer/mod.rs index 354e9e7c2b..0b6cf26a37 100644 --- a/crates/execution/execute-helper/src/observer/exec_tracer/mod.rs +++ b/crates/execution/execute-helper/src/observer/exec_tracer/mod.rs @@ -29,6 +29,7 @@ use cfx_executor::{ }; use cfx_types::{Address, Space, U256}; use cfx_vm_types::ActionParams; +use rlp_bool::CompatibleBool; use typemap::ShareDebugMap; /// Simple executive tracer. Traces all calls and creates. @@ -47,7 +48,10 @@ impl ExecTracer { self.traces .into_iter() .zip(validity.into_iter()) - .map(|(action, valid)| ExecTrace { action, valid }) + .map(|(action, valid)| ExecTrace { + action, + valid: CompatibleBool(valid), + }) .collect() } } diff --git a/crates/execution/execute-helper/src/observer/exec_tracer/phantom_traces.rs b/crates/execution/execute-helper/src/observer/exec_tracer/phantom_traces.rs index 4c4cbe3032..dd4e045be4 100644 --- a/crates/execution/execute-helper/src/observer/exec_tracer/phantom_traces.rs +++ b/crates/execution/execute-helper/src/observer/exec_tracer/phantom_traces.rs @@ -17,6 +17,7 @@ use cfx_executor::{ use cfx_parameters::internal_contract_addresses::CROSS_SPACE_CONTRACT_ADDRESS; use cfx_types::{Address, AddressWithSpace, Space, H256, U256}; use cfx_vm_types::CallType; +use rlp_bool::CompatibleBool; use solidity_abi::ABIEncodable; pub fn recover_phantom_trace_for_withdraw( @@ -55,7 +56,7 @@ pub fn recover_phantom_trace_for_withdraw( input: Default::default(), call_type: CallType::Call, }), - valid: true, + valid: CompatibleBool(true), }, ExecTrace { action: Action::CallResult(CallResult { @@ -63,7 +64,7 @@ pub fn recover_phantom_trace_for_withdraw( gas_left: 0.into(), return_data: Default::default(), }), - valid: true, + valid: CompatibleBool(true), }, ])]); } @@ -113,7 +114,7 @@ pub fn recover_phantom_trace_for_call( input, call_type: CallType::Call, }), - valid: true, + valid: CompatibleBool(true), }, ExecTrace { action: Action::CallResult(CallResult { @@ -121,7 +122,7 @@ pub fn recover_phantom_trace_for_call( gas_left: 0.into(), return_data: Default::default(), }), - valid: true, + valid: CompatibleBool(true), }, ])); } @@ -212,7 +213,7 @@ pub fn recover_phantom_traces( input, .. }) if to == CROSS_SPACE_CONTRACT_ADDRESS - && trace.valid + && trace.valid.into() && is_call_create_sig(&input[0..4]) => { let phantom_traces = recover_phantom_trace_for_call( @@ -231,7 +232,7 @@ pub fn recover_phantom_traces( input, .. }) if to == CROSS_SPACE_CONTRACT_ADDRESS - && trace.valid + && trace.valid.into() && is_withdraw_sig(&input[0..4]) => { let phantom_traces = diff --git a/crates/execution/execute-helper/src/phantom_tx/mod.rs b/crates/execution/execute-helper/src/phantom_tx/mod.rs index 6880911983..1ba3e9f6bf 100644 --- a/crates/execution/execute-helper/src/phantom_tx/mod.rs +++ b/crates/execution/execute-helper/src/phantom_tx/mod.rs @@ -5,8 +5,8 @@ use primitives::{ transaction::eth_transaction::Eip155Transaction, Action, LogEntry, Receipt, SignedTransaction, TransactionStatus, }; - pub use recover::{build_bloom_and_recover_phantom, recover_phantom}; +use rlp_bool::LegacyBool; #[derive(Clone, Debug, Default)] pub struct PhantomTransaction { @@ -56,13 +56,13 @@ impl PhantomTransaction { Receipt { accumulated_gas_used, gas_fee: 0.into(), - gas_sponsor_paid: false, + gas_sponsor_paid: LegacyBool(false), log_bloom: self.log_bloom, logs: self.logs, outcome_status: self.outcome_status, storage_collateralized: vec![], storage_released: vec![], - storage_sponsor_paid: false, + storage_sponsor_paid: LegacyBool(false), burnt_gas_fee: None, } } diff --git a/crates/execution/executor/src/builtin/mod.rs b/crates/execution/executor/src/builtin/mod.rs index 29603842af..343734a975 100644 --- a/crates/execution/executor/src/builtin/mod.rs +++ b/crates/execution/executor/src/builtin/mod.rs @@ -810,7 +810,7 @@ impl Bn128PairingImpl { }; let mut buf = [0u8; 32]; - ret_val.to_big_endian(&mut buf); + ret_val.write_as_big_endian(&mut buf); output.write(0, &buf); Ok(()) diff --git a/crates/execution/executor/src/executive/tests.rs b/crates/execution/executor/src/executive/tests.rs index a21e858f8e..477dd58397 100644 --- a/crates/execution/executor/src/executive/tests.rs +++ b/crates/execution/executor/src/executive/tests.rs @@ -2325,7 +2325,7 @@ fn test_tload() { assert!(apply_state); let mut key = [0u8; 32]; - U256::from(2).to_big_endian(&mut key); + U256::from(2).write_as_big_endian(&mut key); assert_eq!( state .storage_at(&contract_address_with_space, &key) diff --git a/crates/execution/executor/src/internal_contract/components/storage_layout.rs b/crates/execution/executor/src/internal_contract/components/storage_layout.rs index 453121e139..528c393644 100644 --- a/crates/execution/executor/src/internal_contract/components/storage_layout.rs +++ b/crates/execution/executor/src/internal_contract/components/storage_layout.rs @@ -4,8 +4,8 @@ use keccak_hash::keccak; // General function for solidity storage rule pub fn mapping_slot(base: U256, index: U256) -> U256 { let mut input = [0u8; 64]; - base.to_big_endian(&mut input[32..]); - index.to_big_endian(&mut input[..32]); + base.write_as_big_endian(&mut input[32..]); + index.write_as_big_endian(&mut input[..32]); let hash = keccak(input); U256::from_big_endian(hash.as_ref()) } @@ -19,7 +19,7 @@ pub fn vector_slot(base: U256, index: usize, size: usize) -> U256 { pub fn dynamic_slot(base: U256) -> U256 { let mut input = [0u8; 32]; - base.to_big_endian(&mut input); + base.write_as_big_endian(&mut input); let hash = keccak(input); return U256::from_big_endian(hash.as_ref()); } @@ -35,6 +35,6 @@ pub fn array_slot(base: U256, index: usize, element_size: usize) -> U256 { pub fn u256_to_array(input: U256) -> [u8; 32] { let mut answer = [0u8; 32]; - input.to_big_endian(answer.as_mut()); + input.write_as_big_endian(answer.as_mut()); answer } diff --git a/crates/execution/executor/src/state/state_object/tests.rs b/crates/execution/executor/src/state/state_object/tests.rs index 610eb58056..69ac63b271 100644 --- a/crates/execution/executor/src/state/state_object/tests.rs +++ b/crates/execution/executor/src/state/state_object/tests.rs @@ -41,7 +41,7 @@ pub fn get_state_for_genesis_write() -> State { fn u256_to_vec(val: &U256) -> Vec { let mut key = vec![0; 32]; - val.to_big_endian(key.as_mut()); + val.write_as_big_endian(key.as_mut()); key } diff --git a/crates/execution/geth-tracer/src/utils.rs b/crates/execution/geth-tracer/src/utils.rs index a6e29e7c53..e687f57c6a 100644 --- a/crates/execution/geth-tracer/src/utils.rs +++ b/crates/execution/geth-tracer/src/utils.rs @@ -72,7 +72,7 @@ pub(crate) fn stack_push_count( // convert from cfx U256 to alloy U256 pub fn to_alloy_u256(u: U256) -> RU256 { let mut be_bytes: [u8; 32] = [0; 32]; - u.to_big_endian(&mut be_bytes); + u.write_as_big_endian(&mut be_bytes); RU256::from_be_bytes(be_bytes) } diff --git a/crates/execution/parity-trace-types/Cargo.toml b/crates/execution/parity-trace-types/Cargo.toml index 085c86bf40..02655842ba 100644 --- a/crates/execution/parity-trace-types/Cargo.toml +++ b/crates/execution/parity-trace-types/Cargo.toml @@ -25,3 +25,4 @@ cfx-vm-types = { workspace = true } serde = { workspace = true, features = ["rc"] } strum_macros = { workspace = true } cfx-util-macros = { workspace = true } +rlp-bool = { workspace = true } \ No newline at end of file diff --git a/crates/execution/parity-trace-types/src/tests.rs b/crates/execution/parity-trace-types/src/tests.rs index 0ce2790eaa..f1791c28c5 100644 --- a/crates/execution/parity-trace-types/src/tests.rs +++ b/crates/execution/parity-trace-types/src/tests.rs @@ -4,7 +4,7 @@ use super::{ }; use cfx_vm_types::CallType; use rlp::*; - +use rlp_bool::CompatibleBool; #[test] fn encode_flat_transaction_traces() { let ftt = TransactionExecTraces::from(Vec::new()); @@ -43,7 +43,7 @@ fn test_trace_serialization() { input: vec![], call_type: CallType::Call, }), - valid: true, + valid: CompatibleBool(true), }; let flat_trace1 = ExecTrace { @@ -56,7 +56,7 @@ fn test_trace_serialization() { input: vec![0x41, 0xc0, 0xe1, 0xb5], call_type: CallType::Call, }), - valid: true, + valid: CompatibleBool(true), }; let block_traces = BlockExecTraces(vec![ diff --git a/crates/execution/parity-trace-types/src/trace_types.rs b/crates/execution/parity-trace-types/src/trace_types.rs index 82820eca8b..1995f6d8c9 100644 --- a/crates/execution/parity-trace-types/src/trace_types.rs +++ b/crates/execution/parity-trace-types/src/trace_types.rs @@ -8,6 +8,7 @@ use cfx_internal_common::{DatabaseDecodable, DatabaseEncodable}; use cfx_types::{Bloom, Space, H256, U256, U64}; use malloc_size_of_derive::MallocSizeOf; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; +use rlp_bool::CompatibleBool; use rlp_derive::{RlpDecodable, RlpEncodable}; /// Trace localized in vector of traces produced by a single transaction. @@ -18,7 +19,7 @@ pub struct ExecTrace { #[ignore_malloc_size_of = "ignored for performance reason"] /// Type of action performed by a transaction. pub action: Action, - pub valid: bool, + pub valid: CompatibleBool, } impl ExecTrace { @@ -39,7 +40,7 @@ impl Decodable for ExecTrace { match d.item_count()? { 1 => Ok(ExecTrace { action: d.val_at(0)?, - valid: true, + valid: CompatibleBool(true), }), 2 => Ok(ExecTrace { action: d.val_at(0)?, @@ -135,5 +136,5 @@ impl DatabaseDecodable for BlockExecTraces { } impl DatabaseEncodable for BlockExecTraces { - fn db_encode(&self) -> Bytes { rlp::encode(self) } + fn db_encode(&self) -> Bytes { rlp::encode(self).into() } } diff --git a/crates/execution/solidity-abi/src/basic.rs b/crates/execution/solidity-abi/src/basic.rs index 7374196a7c..73466df602 100644 --- a/crates/execution/solidity-abi/src/basic.rs +++ b/crates/execution/solidity-abi/src/basic.rs @@ -36,7 +36,7 @@ impl ABIVariable for U256 { fn to_abi(&self) -> LinkedBytes { let mut answer = vec![0u8; 32]; - self.to_big_endian(&mut answer); + self.write_as_big_endian(&mut answer); LinkedBytes::from_bytes(answer) } diff --git a/crates/execution/solidity-abi/src/utils.rs b/crates/execution/solidity-abi/src/utils.rs index 74987d4008..f8ea1005fa 100644 --- a/crates/execution/solidity-abi/src/utils.rs +++ b/crates/execution/solidity-abi/src/utils.rs @@ -14,7 +14,7 @@ pub struct LinkedBytes { pub fn padded_big_endian(length: usize) -> Vec { let mut bytes = [0u8; 32]; - U256::from(length).to_big_endian(&mut bytes); + U256::from(length).write_as_big_endian(&mut bytes); bytes.to_vec() } diff --git a/crates/execution/vm-interpreter/src/interpreter/gasometer.rs b/crates/execution/vm-interpreter/src/interpreter/gasometer.rs index a43dceeffe..69e0301aee 100644 --- a/crates/execution/vm-interpreter/src/interpreter/gasometer.rs +++ b/crates/execution/vm-interpreter/src/interpreter/gasometer.rs @@ -150,7 +150,7 @@ impl Gasometer { instructions::SLOAD => { let gas = if spec.cip645.eip_cold_warm_access { let mut key = H256::zero(); - stack.peek(0).to_big_endian(&mut key.0); + stack.peek(0).write_as_big_endian(&mut key.0); if context.is_warm_storage_entry(&key)? { spec.warm_access_gas } else { @@ -532,7 +532,7 @@ fn calc_sstore_gas( } let mut key = H256::zero(); - stack.peek(0).to_big_endian(&mut key.0); + stack.peek(0).write_as_big_endian(&mut key.0); let new_val = *stack.peek(1); let warm_val = context.is_warm_storage_entry(&key)?; diff --git a/crates/execution/vm-interpreter/src/interpreter/memory.rs b/crates/execution/vm-interpreter/src/interpreter/memory.rs index 31ca581f95..293e695772 100644 --- a/crates/execution/vm-interpreter/src/interpreter/memory.rs +++ b/crates/execution/vm-interpreter/src/interpreter/memory.rs @@ -68,7 +68,7 @@ impl Memory for Vec { fn read(&self, offset: U256) -> U256 { let off = offset.low_u64() as usize; - U256::from(&self[off..off + 32]) + U256::from_big_endian(&self[off..off + 32]) } fn writeable_slice(&mut self, offset: U256, size: U256) -> &mut [u8] { @@ -90,7 +90,7 @@ impl Memory for Vec { fn write(&mut self, offset: U256, value: U256) { let off = offset.low_u64() as usize; - value.to_big_endian(&mut self[off..off + 32]); + value.write_as_big_endian(&mut self[off..off + 32]); } fn write_byte(&mut self, offset: U256, value: U256) { diff --git a/crates/execution/vm-interpreter/src/interpreter/mod.rs b/crates/execution/vm-interpreter/src/interpreter/mod.rs index e1f51b711a..ebfbd4877d 100644 --- a/crates/execution/vm-interpreter/src/interpreter/mod.rs +++ b/crates/execution/vm-interpreter/src/interpreter/mod.rs @@ -86,7 +86,7 @@ impl CodeReader { let pos = self.position; self.position += no_of_bytes; let max = cmp::min(pos + no_of_bytes, self.code.len()); - U256::from(&self.code[pos..max]) + U256::from_big_endian(&self.code[pos..max]) } fn len(&self) -> usize { self.code.len() } @@ -688,7 +688,7 @@ impl Interpreter { } else { // TLOAD let mut key = vec![0; 32]; - self.stack.pop_back().to_big_endian(key.as_mut()); + self.stack.pop_back().write_as_big_endian(key.as_mut()); let word = if context.spec().cip154 { context.transient_storage_at(&key)? } else { @@ -731,7 +731,7 @@ impl Interpreter { } else { // TSTORE let mut key = vec![0; 32]; - self.stack.pop_back().to_big_endian(key.as_mut()); + self.stack.pop_back().write_as_big_endian(key.as_mut()); let val = self.stack.pop_back(); context.transient_set_storage(key, val)?; @@ -1090,13 +1090,13 @@ impl Interpreter { } instructions::SLOAD => { let mut key = vec![0; 32]; - self.stack.pop_back().to_big_endian(key.as_mut()); + self.stack.pop_back().write_as_big_endian(key.as_mut()); let word = context.storage_at(&key)?; self.stack.push(word); } instructions::SSTORE => { let mut key = vec![0; 32]; - self.stack.pop_back().to_big_endian(key.as_mut()); + self.stack.pop_back().write_as_big_endian(key.as_mut()); let val = self.stack.pop_back(); context.set_storage(key, val)?; @@ -1139,7 +1139,7 @@ impl Interpreter { if id < bound && big_id < U256::from(data.len()) { let mut v = [0u8; 32]; v[0..bound - id].clone_from_slice(&data[id..bound]); - self.stack.push(U256::from(&v[..])) + self.stack.push(U256::from_big_endian(&v[..])) } else { self.stack.push(U256::zero()) } diff --git a/crates/execution/vm-interpreter/src/tests.rs b/crates/execution/vm-interpreter/src/tests.rs index 77cabfb106..9f6345856e 100644 --- a/crates/execution/vm-interpreter/src/tests.rs +++ b/crates/execution/vm-interpreter/src/tests.rs @@ -1329,7 +1329,7 @@ fn assert_set_contains( fn assert_store(ctx: &MockContext, pos: u64, val: &str) { let mut key = vec![0; 32]; - U256::from(pos).to_big_endian(key.as_mut()); + U256::from(pos).write_as_big_endian(key.as_mut()); assert_eq!( ctx.store.get(&key).unwrap(), &H256::from_str(val).unwrap().into_uint() diff --git a/crates/network/src/discovery.rs b/crates/network/src/discovery.rs index b875d14f7d..66c543afda 100644 --- a/crates/network/src/discovery.rs +++ b/crates/network/src/discovery.rs @@ -173,7 +173,7 @@ impl Discovery { uio, PACKET_PING, &node.endpoint.udp_address(), - &rlp.drain(), + &rlp.as_raw(), )?; self.in_flight_pings.insert( @@ -286,7 +286,7 @@ impl Discovery { response.append(&echo_hash); response.append(&self.config.expire_timestamp()); - self.send_packet(uio, PACKET_PONG, from, &response.drain())?; + self.send_packet(uio, PACKET_PONG, from, &response.as_raw())?; let entry = NodeEntry { id: node_id.clone(), diff --git a/crates/network/src/session.rs b/crates/network/src/session.rs index b33953ab81..87b1310a7a 100644 --- a/crates/network/src/session.rs +++ b/crates/network/src/session.rs @@ -582,7 +582,7 @@ impl Session { None, ProtocolVersion::default(), PACKET_DISCONNECT, - packet, + packet.into(), ); Error::Disconnect(reason).into() } @@ -607,7 +607,7 @@ impl Session { None, ProtocolVersion::default(), PACKET_HELLO, - rlp.drain(), + rlp.out().into(), SendQueuePriority::High, ) .map(|_| ()) diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index c8b82ac59e..ed3448b47a 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -22,6 +22,7 @@ siphasher = { workspace = true } unexpected = { workspace = true } once_cell = { workspace = true } cfx-parameters = { workspace = true } +rlp-bool = { workspace = true } [dev-dependencies] criterion = { workspace = true } @@ -36,4 +37,4 @@ harness = false # we have to define a feature for test code. # https://users.rust-lang.org/t/cfg-test-doesnt-propagate-to-external-crates/13046 [features] -test_no_account_length_check = [] \ No newline at end of file +test_no_account_length_check = [] diff --git a/crates/primitives/src/block.rs b/crates/primitives/src/block.rs index 22b4c1e7bf..6d45f79771 100644 --- a/crates/primitives/src/block.rs +++ b/crates/primitives/src/block.rs @@ -140,7 +140,7 @@ impl Block { for tx in &self.transactions { stream.append(tx.as_ref()); } - stream.drain() + stream.out().into() } pub fn decode_body_with_tx_public( @@ -165,7 +165,7 @@ impl Block { .begin_list(2) .append(&self.block_header) .append_raw(&*self.encode_body_with_tx_public(), 1); - stream.drain() + stream.out().into() } pub fn decode_with_tx_public(rlp: &Rlp) -> Result { diff --git a/crates/primitives/src/block_header.rs b/crates/primitives/src/block_header.rs index bfa3a55cf4..6b2b93c6f7 100644 --- a/crates/primitives/src/block_header.rs +++ b/crates/primitives/src/block_header.rs @@ -19,6 +19,7 @@ use cfx_types::{ use malloc_size_of::{new_malloc_size_ops, MallocSizeOf, MallocSizeOfOps}; use once_cell::sync::OnceCell; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; +use rlp_bool::LegacyBool; use rlp_derive::{RlpDecodable, RlpEncodable}; use std::{ mem, @@ -59,7 +60,7 @@ pub struct BlockHeaderRlpPart { /// Block difficulty. difficulty: U256, /// Whether it is an adaptive block (from GHAST algorithm) - adaptive: bool, + adaptive: LegacyBool, /// Gas limit. gas_limit: U256, /// Referee hashes @@ -166,7 +167,7 @@ impl BlockHeader { pub fn difficulty(&self) -> &U256 { &self.difficulty } /// Get the adaptive field of the header - pub fn adaptive(&self) -> bool { self.adaptive } + pub fn adaptive(&self) -> bool { self.adaptive.into() } /// Get the gas limit field of the header. pub fn gas_limit(&self) -> &U256 { &self.gas_limit } @@ -241,19 +242,23 @@ impl BlockHeader { pub fn rlp_without_nonce(&self) -> Bytes { let mut stream = RlpStream::new(); self.stream_rlp_without_nonce(&mut stream); - stream.out() + stream.as_raw().into() } /// Get the RLP representation of this header. pub fn rlp(&self) -> Bytes { let mut stream = RlpStream::new(); self.stream_rlp(&mut stream); - stream.out() + stream.out().into() } /// Place this header(except nonce) into an RLP stream `stream`. fn stream_rlp_without_nonce(&self, stream: &mut RlpStream) { - let adaptive_n = if self.adaptive { 1 as u8 } else { 0 as u8 }; + let adaptive_n = if self.adaptive.into() { + 1 as u8 + } else { + 0 as u8 + }; let list_len = HEADER_LIST_MIN_LEN + self.pos_reference.is_some() as usize + self.base_price.is_some() as usize @@ -293,7 +298,11 @@ impl BlockHeader { /// Place this header into an RLP stream `stream`. fn stream_rlp(&self, stream: &mut RlpStream) { - let adaptive_n = if self.adaptive { 1 as u8 } else { 0 as u8 }; + let adaptive_n = if self.adaptive.into() { + 1 as u8 + } else { + 0 as u8 + }; let list_len = HEADER_LIST_MIN_LEN + 1 + self.pos_reference.is_some() as usize @@ -334,7 +343,11 @@ impl BlockHeader { /// Place this header and its `pow_hash` into an RLP stream `stream`. pub fn stream_rlp_with_pow_hash(&self, stream: &mut RlpStream) { - let adaptive_n = if self.adaptive { 1 as u8 } else { 0 as u8 }; + let adaptive_n = if self.adaptive.into() { + 1 as u8 + } else { + 0 as u8 + }; let list_len = HEADER_LIST_MIN_LEN + 2 + self.pos_reference.is_some() as usize @@ -390,7 +403,7 @@ impl BlockHeader { deferred_logs_bloom_hash: r.val_at(7)?, blame: r.val_at(8)?, difficulty: r.val_at(9)?, - adaptive: r.val_at::(10)? == 1, + adaptive: LegacyBool(r.val_at::(10)? == 1), gas_limit: r.val_at(11)?, referee_hashes: r.list_at(12)?, custom: vec![], @@ -589,7 +602,7 @@ impl BlockHeaderBuilder { deferred_logs_bloom_hash: self.deferred_logs_bloom_hash, blame: self.blame, difficulty: self.difficulty, - adaptive: self.adaptive, + adaptive: self.adaptive.into(), gas_limit: self.gas_limit, referee_hashes: self.referee_hashes.clone(), custom: self.custom.clone(), @@ -672,7 +685,7 @@ impl Decodable for BlockHeader { deferred_logs_bloom_hash: r.val_at(7)?, blame: r.val_at(8)?, difficulty: r.val_at(9)?, - adaptive: r.val_at::(10)? == 1, + adaptive: LegacyBool(r.val_at::(10)? == 1), gas_limit: r.val_at(11)?, referee_hashes: r.list_at(12)?, custom: vec![], @@ -720,6 +733,7 @@ mod tests { TransactionStatus, }; use cfx_types::{Bloom, KECCAK_EMPTY_BLOOM, U256}; + use rlp_bool::LegacyBool; use std::{str::FromStr, sync::Arc}; #[test] @@ -747,11 +761,11 @@ mod tests { let receipt = Receipt { accumulated_gas_used: U256::zero(), gas_fee: U256::zero(), - gas_sponsor_paid: false, + gas_sponsor_paid: LegacyBool(false), logs: vec![], outcome_status: TransactionStatus::Success, log_bloom: Bloom::zero(), - storage_sponsor_paid: false, + storage_sponsor_paid: LegacyBool(false), storage_collateralized: vec![], storage_released: vec![], burnt_gas_fee: None, @@ -779,7 +793,7 @@ mod tests { Receipt { accumulated_gas_used: 0.into(), gas_fee: 0.into(), - gas_sponsor_paid: false, + gas_sponsor_paid: LegacyBool(false), logs: vec![], outcome_status: TransactionStatus::Success, log_bloom: Bloom::from_str( @@ -801,7 +815,7 @@ mod tests { 00000000000000000000000000000000", ) .unwrap(), - storage_sponsor_paid: false, + storage_sponsor_paid: LegacyBool(false), storage_collateralized: vec![], storage_released: vec![], burnt_gas_fee: None, @@ -809,7 +823,7 @@ mod tests { Receipt { accumulated_gas_used: U256::zero(), gas_fee: U256::zero(), - gas_sponsor_paid: false, + gas_sponsor_paid: LegacyBool(false), logs: vec![], outcome_status: TransactionStatus::Success, log_bloom: Bloom::from_str( @@ -831,7 +845,7 @@ mod tests { 00000000000000000000000000000000", ) .unwrap(), - storage_sponsor_paid: false, + storage_sponsor_paid: LegacyBool(false), storage_collateralized: vec![], storage_released: vec![], burnt_gas_fee: None, @@ -846,7 +860,7 @@ mod tests { receipts: vec![Receipt { accumulated_gas_used: U256::zero(), gas_fee: U256::zero(), - gas_sponsor_paid: false, + gas_sponsor_paid: LegacyBool(false), logs: vec![], outcome_status: TransactionStatus::Success, log_bloom: Bloom::from_str( @@ -868,7 +882,7 @@ mod tests { 00000000000000000000000000000000", ) .unwrap(), - storage_sponsor_paid: false, + storage_sponsor_paid: LegacyBool(false), storage_collateralized: vec![], storage_released: vec![], burnt_gas_fee: None, diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index 54ef026d9c..773edcfc96 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -6,6 +6,7 @@ use crate::log_entry::LogEntry; use cfx_types::{Address, Bloom, Space, U256, U64}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; +use rlp_bool::LegacyBool; use rlp_derive::{RlpDecodable, RlpEncodable}; pub const TRANSACTION_OUTCOME_SUCCESS: u8 = 0; @@ -99,7 +100,7 @@ pub struct Receipt { /// The gas fee charged for transaction execution. pub gas_fee: U256, /// The designated account to bear the gas fee, if any. - pub gas_sponsor_paid: bool, + pub gas_sponsor_paid: LegacyBool, /// The OR-wide combination of all logs' blooms for this transaction. pub log_bloom: Bloom, /// The logs stemming from this transaction. @@ -107,7 +108,7 @@ pub struct Receipt { /// Transaction outcome. pub outcome_status: TransactionStatus, /// The designated account to bear the storage fee, if any. - pub storage_sponsor_paid: bool, + pub storage_sponsor_paid: LegacyBool, pub storage_collateralized: Vec, pub storage_released: Vec, pub burnt_gas_fee: Option, @@ -167,11 +168,11 @@ impl Receipt { Self { accumulated_gas_used, gas_fee, - gas_sponsor_paid, + gas_sponsor_paid: LegacyBool(gas_sponsor_paid), log_bloom, logs, outcome_status: outcome, - storage_sponsor_paid, + storage_sponsor_paid: LegacyBool(storage_sponsor_paid), storage_collateralized, storage_released, burnt_gas_fee, diff --git a/crates/primitives/src/transaction/eth_transaction.rs b/crates/primitives/src/transaction/eth_transaction.rs index dbfbb98ea9..598cfbdae6 100644 --- a/crates/primitives/src/transaction/eth_transaction.rs +++ b/crates/primitives/src/transaction/eth_transaction.rs @@ -28,8 +28,8 @@ impl Eip155Transaction { // phantom transactions with matching // fields from different senders // will have different hashes - r: U256::from(from.address.as_ref()), - s: U256::from(from.address.as_ref()), + r: U256::from_big_endian(from.address.as_ref()), + s: U256::from_big_endian(from.address.as_ref()), v: 0, }, hash: H256::zero(), diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 10f616e18a..6b41f0d6ec 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -522,8 +522,8 @@ impl Transaction { TransactionWithSignature { transaction: TransactionWithSignatureSerializePart { unsigned: self, - r: sig.r().into(), - s: sig.s().into(), + r: U256::from_big_endian(sig.r()), + s: U256::from_big_endian(sig.s()), v: sig.v(), }, hash: H256::zero(), diff --git a/crates/primitives/src/transaction_index.rs b/crates/primitives/src/transaction_index.rs index d4389022dc..5585db64e0 100644 --- a/crates/primitives/src/transaction_index.rs +++ b/crates/primitives/src/transaction_index.rs @@ -5,7 +5,7 @@ use cfx_types::H256; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; - +use rlp_bool::CompatibleBool; /// Represents address of certain transaction within block #[derive(Debug, PartialEq, Eq, Hash, Clone, Default)] pub struct TransactionIndex { @@ -14,7 +14,7 @@ pub struct TransactionIndex { /// Transaction index within the block pub real_index: usize, /// true when this index belongs to a phantom transaction - pub is_phantom: bool, + pub is_phantom: CompatibleBool, /// Transaction index to be used in RPC responses pub rpc_index: Option, } @@ -39,7 +39,7 @@ impl Decodable for TransactionIndex { 2 => Ok(TransactionIndex { block_hash: rlp.val_at(0)?, real_index: rlp.val_at(1)?, - is_phantom: false, + is_phantom: CompatibleBool(false), rpc_index: None, }), 3 => Ok(TransactionIndex { diff --git a/crates/rpc/rpc-cfx-impl/src/trace_handler.rs b/crates/rpc/rpc-cfx-impl/src/trace_handler.rs index 3743b0f307..394ef3e353 100644 --- a/crates/rpc/rpc-cfx-impl/src/trace_handler.rs +++ b/crates/rpc/rpc-cfx-impl/src/trace_handler.rs @@ -118,7 +118,7 @@ impl TraceHandler { .transaction_index_by_hash(tx_hash, true /* update_cache */)?; // FIXME(thegaram): do we support traces for phantom txs? - if tx_index.is_phantom { + if tx_index.is_phantom.into() { return None; } @@ -156,7 +156,7 @@ impl TraceHandler { .map(|trace| RpcLocalizedTrace { action: RpcAction::try_from(trace.action, self.network) .expect("local address convert error"), - valid: trace.valid, + valid: trace.valid.into(), epoch_hash: Some(pivot_hash), epoch_number: Some(epoch_number.into()), block_hash: Some(tx_index.block_hash), diff --git a/crates/rpc/rpc-cfx-types/Cargo.toml b/crates/rpc/rpc-cfx-types/Cargo.toml index 82af34d3a7..415d970c6d 100644 --- a/crates/rpc/rpc-cfx-types/Cargo.toml +++ b/crates/rpc/rpc-cfx-types/Cargo.toml @@ -28,7 +28,7 @@ cfx-util-macros = { workspace = true } log = { workspace = true } cfx-parity-trace-types = { workspace = true } parity-version = { workspace = true } -rand_07 = { workspace = true } +rand_08 = { workspace = true } diem-crypto = { workspace = true } diem-types = { workspace = true } rustc-hex = { workspace = true } diff --git a/crates/rpc/rpc-cfx-types/src/subscriber_id.rs b/crates/rpc/rpc-cfx-types/src/subscriber_id.rs index c4986dea28..b512101841 100644 --- a/crates/rpc/rpc-cfx-types/src/subscriber_id.rs +++ b/crates/rpc/rpc-cfx-types/src/subscriber_id.rs @@ -23,9 +23,9 @@ impl SubId { } pub mod random { - use rand_07; + use rand_08::rngs::OsRng; - pub type Rng = rand_07::rngs::OsRng; + pub type Rng = OsRng; - pub fn new() -> Rng { rand_07::rngs::OsRng } + pub fn new() -> Rng { OsRng } } diff --git a/crates/rpc/rpc-cfx-types/src/trace.rs b/crates/rpc/rpc-cfx-types/src/trace.rs index 31fd113e4b..6c6d729720 100644 --- a/crates/rpc/rpc-cfx-types/src/trace.rs +++ b/crates/rpc/rpc-cfx-types/src/trace.rs @@ -408,7 +408,7 @@ impl LocalizedTransactionTrace { Action::try_from(t.action, network).map(|action| { LocalizedTrace { action, - valid, + valid: valid.into(), // Set to None because the information has been // included in the outer // structs diff --git a/crates/rpc/rpc-common-impl/src/trace/conversion.rs b/crates/rpc/rpc-common-impl/src/trace/conversion.rs index 0d43db7943..ab1afe861e 100644 --- a/crates/rpc/rpc-common-impl/src/trace/conversion.rs +++ b/crates/rpc/rpc-common-impl/src/trace/conversion.rs @@ -34,7 +34,7 @@ pub fn into_eth_localized_traces( block_number, block_hash, // action and its result should have the same `valid`. - valid: action.valid, + valid: action.valid.into(), }; eth_trace.set_result(Some(result.action.clone())).expect( @@ -58,7 +58,7 @@ pub fn into_eth_localized_traces( block_number, block_hash, // action and its result should have the same `valid`. - valid: action.valid, + valid: action.valid.into(), }; eth_traces.push(eth_trace); @@ -83,7 +83,7 @@ pub fn primitive_traces_to_eth_localized_traces( .iter() .map(|x| ExecTrace { action: x.action.clone(), - valid: x.valid, + valid: x.valid.into(), }) .collect(); let eth_traces = into_eth_localized_traces( diff --git a/crates/rpc/rpc-eth-types/src/transaction.rs b/crates/rpc/rpc-eth-types/src/transaction.rs index ce524547bd..3ef186da77 100644 --- a/crates/rpc/rpc-eth-types/src/transaction.rs +++ b/crates/rpc/rpc-eth-types/src/transaction.rs @@ -123,8 +123,8 @@ impl Transaction { // for phantom tx, it's r and s are set to 'tx.from', which lead some // txs r and s to 0 which is not valid in some ethereum tools, // so we set them to chain_id - let mut r: U256 = signature.r().into(); - let mut s: U256 = signature.s().into(); + let mut r: U256 = U256::from_big_endian(signature.r()); + let mut s: U256 = U256::from_big_endian(signature.s()); if r == U256::zero() || s == U256::zero() { let chain_id = t .chain_id() @@ -150,7 +150,7 @@ impl Transaction { gas: *t.gas(), input: Bytes::new(t.data().clone()), creates: exec_info.1, - raw: Some(Bytes::new(t.transaction.transaction.rlp_bytes())), + raw: Some(Bytes::new(t.transaction.transaction.rlp_bytes().into())), public_key: t.public().map(Into::into), chain_id: t.chain_id().map(|x| U64::from(x as u64)), standard_v: Some(signature.v().into()), diff --git a/crates/rpc/rpc-primitives/Cargo.toml b/crates/rpc/rpc-primitives/Cargo.toml index dfcae686c3..39631329b1 100644 --- a/crates/rpc/rpc-primitives/Cargo.toml +++ b/crates/rpc/rpc-primitives/Cargo.toml @@ -14,6 +14,6 @@ license-file.workspace = true [dependencies] rustc-hex = { workspace = true } -serde = { workspace = true } +serde = { workspace = true, features = ["std"] } serde_json = { workspace = true } serde-utils = { workspace = true } diff --git a/crates/util/log_device/src/lib.rs b/crates/util/log_device/src/lib.rs index 6ed1a23151..3fdfb6eed6 100644 --- a/crates/util/log_device/src/lib.rs +++ b/crates/util/log_device/src/lib.rs @@ -243,7 +243,7 @@ impl LogDevice { fn set_stripe_info_to_db(&self, key: &[u8], stripe_info: &StripeInfo) { let value = rlp::encode(stripe_info); let mut tx = DBTransaction::new(); - tx.put(COL_DB, key, value.as_slice()); + tx.put(COL_DB, key, value.as_ref()); self.db.key_value().write(tx).expect("DB write failed."); } diff --git a/crates/util/rlp_bool/Cargo.toml b/crates/util/rlp_bool/Cargo.toml new file mode 100644 index 0000000000..b0b2f61def --- /dev/null +++ b/crates/util/rlp_bool/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "rlp-bool" +version.workspace = true +authors.workspace = true +description.workspace = true +documentation.workspace = true +homepage.workspace = true +keywords.workspace = true +repository.workspace = true +license-file.workspace = true +edition.workspace = true + +[dependencies] +rlp = { workspace = true } +malloc_size_of_derive = { workspace = true } +malloc_size_of = { workspace = true } \ No newline at end of file diff --git a/crates/util/rlp_bool/src/bool.rs b/crates/util/rlp_bool/src/bool.rs new file mode 100644 index 0000000000..fc00014f31 --- /dev/null +++ b/crates/util/rlp_bool/src/bool.rs @@ -0,0 +1,153 @@ +use std::iter::once; + +use malloc_size_of_derive::MallocSizeOf as DeriveMallocSizeOf; +use rlp::{Decodable, Encodable}; +/// Legacy boolean type for RLP encoding: +/// - encodes `true` as `0x01` and `false` as `0x00`. +/// - decodes `0x01` as `true`, `0x00` as `false` +/// - any other value is an error. +#[derive( + Debug, Clone, PartialEq, Eq, Copy, Default, Hash, DeriveMallocSizeOf, +)] +pub struct LegacyBool(pub bool); + +impl Encodable for LegacyBool { + fn rlp_append(&self, s: &mut rlp::RlpStream) { + let byte_to_encode = if self.0 { 1u8 } else { 0u8 }; + s.encoder().encode_iter(once(byte_to_encode)); + } +} + +impl Decodable for LegacyBool { + fn decode(rlp: &rlp::Rlp) -> Result { + rlp.decoder().decode_value(|bytes| match bytes.len() { + 0 => Ok(LegacyBool(false)), + 1 => match bytes[0] { + 0 => Ok(LegacyBool(false)), + 1 => Ok(LegacyBool(true)), + _ => Err(rlp::DecoderError::RlpInvalidIndirection), + }, + _ => Err(rlp::DecoderError::RlpIsTooBig), + }) + } +} + +impl From for LegacyBool { + fn from(value: bool) -> Self { LegacyBool(value) } +} + +impl From for bool { + fn from(value: LegacyBool) -> Self { value.0 } +} + +/// Compatible boolean type for RLP encoding: +/// - encodes `true` as `0x01` and `false` as `0x80`. +/// - decodes `0x01` as `true`, `0x80` as `false`, and `0x00` as `false` (legacy +/// behavior). +/// - any other value is an error. +#[derive( + Debug, Clone, PartialEq, Eq, Copy, Default, Hash, DeriveMallocSizeOf, +)] +pub struct CompatibleBool(pub bool); + +impl Encodable for CompatibleBool { + fn rlp_append(&self, s: &mut rlp::RlpStream) { + let as_uint = u8::from(self.0); + Encodable::rlp_append(&as_uint, s); + } +} + +impl Decodable for CompatibleBool { + fn decode(rlp: &rlp::Rlp) -> Result { + rlp.decoder().decode_value(|bytes| match bytes.len() { + 0 => Ok(CompatibleBool(false)), + 1 => match bytes[0] { + 0 => Ok(CompatibleBool(false)), + 1 => Ok(CompatibleBool(true)), + _ => Err(rlp::DecoderError::RlpInvalidIndirection), + }, + _ => Err(rlp::DecoderError::RlpIsTooBig), + }) + } +} + +impl From for CompatibleBool { + fn from(value: bool) -> Self { CompatibleBool(value) } +} +impl From for bool { + fn from(value: CompatibleBool) -> Self { value.0 } +} + +#[cfg(test)] +mod tests { + use super::*; + use rlp::{Rlp, RlpStream}; + + #[test] + fn test_legacy_bool() { + let mut s = RlpStream::new(); + LegacyBool(true).rlp_append(&mut s); + assert_eq!(s.out(), vec![0x01]); + + let mut s = RlpStream::new(); + LegacyBool(false).rlp_append(&mut s); + assert_eq!(s.out(), vec![0x00]); + + // 0x01 => true + assert_eq!( + LegacyBool::decode(&Rlp::new(&[0x01])).unwrap(), + LegacyBool(true) + ); + // 0x00 => false + assert_eq!( + LegacyBool::decode(&Rlp::new(&[0x00])).unwrap(), + LegacyBool(false) + ); + + assert!(LegacyBool::decode(&Rlp::new(&[0x02])).is_err()); + assert!(LegacyBool::decode(&Rlp::new(&[0xff])).is_err()); + } + + #[test] + fn test_compatible_bool() { + let mut s = RlpStream::new(); + CompatibleBool(true).rlp_append(&mut s); + assert_eq!(s.out(), vec![0x01]); + + let mut s = RlpStream::new(); + CompatibleBool(false).rlp_append(&mut s); + assert_eq!(s.out(), vec![0x80]); + + // 0x01 => true + assert_eq!( + CompatibleBool::decode(&Rlp::new(&[0x01])).unwrap(), + CompatibleBool(true) + ); + + // 0x80 => false + assert_eq!( + CompatibleBool::decode(&Rlp::new(&[0x80])).unwrap(), + CompatibleBool(false) + ); + // // 0x00 => false (legacy behavior) + assert_eq!( + CompatibleBool::decode(&Rlp::new(&[0x00])).unwrap(), + CompatibleBool(false) + ); + + // don't accept other values + assert!(CompatibleBool::decode(&Rlp::new(&[0x02])).is_err()); + assert!(CompatibleBool::decode(&Rlp::new(&[0xff])).is_err()); + } + + #[test] + fn test_compatibility() { + let mut s = RlpStream::new(); + LegacyBool(false).rlp_append(&mut s); + + assert_eq!( + CompatibleBool::decode(&Rlp::new(&s.out())).unwrap(), + CompatibleBool(false) + ); + } +} diff --git a/crates/util/rlp_bool/src/lib.rs b/crates/util/rlp_bool/src/lib.rs new file mode 100644 index 0000000000..ef7718ab12 --- /dev/null +++ b/crates/util/rlp_bool/src/lib.rs @@ -0,0 +1,3 @@ +mod bool; + +pub use bool::{CompatibleBool, LegacyBool}; diff --git a/integration_tests/conflux/messages.py b/integration_tests/conflux/messages.py index 00e18bce16..de0229cbf0 100644 --- a/integration_tests/conflux/messages.py +++ b/integration_tests/conflux/messages.py @@ -63,6 +63,7 @@ ) # Copied from rlp.sedes.Boolean, but encode False to 0x00, not empty. +# The current Conflux Rust implementation encodes False to 0x80 and treats both 0x00 and 0x80 as False. class Boolean: """A sedes for booleans """ @@ -78,13 +79,13 @@ def serialize(self, obj): raise Exception("Invariant: no other options for boolean values") def deserialize(self, serial): - if serial == b'\x00': + if serial == b'': return False elif serial == b'\x01': return True else: raise DeserializationError( - 'Invalid serialized boolean. Must be either 0x01 or 0x00', + 'Invalid serialized boolean. Must be either 0x01 or 0x80', serial ) diff --git a/integration_tests/test_framework/util/epoch.py b/integration_tests/test_framework/util/epoch.py deleted file mode 100644 index 2ec9c82b88..0000000000 --- a/integration_tests/test_framework/util/epoch.py +++ /dev/null @@ -1,48 +0,0 @@ -from dataclasses import dataclass -import sys - - -@dataclass -class EpochErrorInfo: - """ - A dataclass to encapsulate information about epoch-related errors. - epoch (any): The epoch value that caused the error. - error_code (int): The error code. - error_msg (callable): A function that takes the type and args as arguments and returns the error message. - """ - - epoch: any - error_code: int - error_msg: str - - -epoch_invalid_epoch_type_error = EpochErrorInfo( - epoch=1, - error_code=-32602, - error_msg="Invalid params: invalid type: integer `1`, expected an epoch number or 'latest_mined', 'latest_state', 'latest_checkpoint', 'latest_finalized', 'latest_confirmed' or 'earliest'.", -) - - -epoch_epoch_number_too_large_error = EpochErrorInfo( - epoch=hex(sys.maxsize), - error_code=-32602, - error_msg="Invalid params: expected a numbers with less than largest epoch number.", -) - -epoch_empty_epoch_string_error = EpochErrorInfo( - epoch="0x", - error_code=-32602, - error_msg="Invalid params: Invalid epoch number: cannot parse integer from empty string.", -) - -epoch_invalid_digit_epoch_error = EpochErrorInfo( - epoch="0xZZZ", - error_code=-32602, - error_msg="Invalid params: Invalid epoch number: invalid digit found in string.", -) - -epoch_missing_hex_prefix_error = EpochErrorInfo( - epoch="-1", - error_code=-32602, - error_msg="Invalid params: Invalid epoch number: missing 0x prefix.", -) diff --git a/integration_tests/tests/rpc/test_block_by_epoch.py b/integration_tests/tests/rpc/test_block_by_epoch.py deleted file mode 100644 index 3c2cdf1f13..0000000000 --- a/integration_tests/tests/rpc/test_block_by_epoch.py +++ /dev/null @@ -1,44 +0,0 @@ -from integration_tests.conflux.rpc import RpcClient -from integration_tests.test_framework.util import assert_raises_rpc_error, assert_equal -from integration_tests.test_framework.util.epoch import ( - epoch_invalid_epoch_type_error, - epoch_epoch_number_too_large_error, - epoch_empty_epoch_string_error, - epoch_invalid_digit_epoch_error, - epoch_missing_hex_prefix_error, -) - - -def test_last_mined(client): - block_hash = client.generate_block() - block = client.block_by_epoch(client.EPOCH_LATEST_MINED) - assert_equal(block["hash"], block_hash) - - -# If this errors is changed, please let me know https://github.com/Conflux-Chain/rpc-errors/issues/new -def test_get_epoch_number_errors(client: RpcClient): - assert_raises_rpc_error( - epoch_epoch_number_too_large_error.error_code, - epoch_epoch_number_too_large_error.error_msg, - client.block_by_epoch, - epoch_epoch_number_too_large_error.epoch, - ) - assert_raises_rpc_error( - epoch_empty_epoch_string_error.error_code, - epoch_empty_epoch_string_error.error_msg, - client.block_by_epoch, - epoch_empty_epoch_string_error.epoch, - ) - assert_raises_rpc_error( - epoch_invalid_digit_epoch_error.error_code, - epoch_invalid_digit_epoch_error.error_msg, - client.block_by_epoch, - epoch_invalid_digit_epoch_error.epoch, - ) - - assert_raises_rpc_error( - epoch_missing_hex_prefix_error.error_code, - epoch_missing_hex_prefix_error.error_msg, - client.block_by_epoch, - epoch_missing_hex_prefix_error.epoch, - ) diff --git a/integration_tests/tests/rpc/test_epoch_number.py b/integration_tests/tests/rpc/test_epoch_number.py deleted file mode 100644 index 7c9d0777ef..0000000000 --- a/integration_tests/tests/rpc/test_epoch_number.py +++ /dev/null @@ -1,44 +0,0 @@ -from integration_tests.conflux.rpc import RpcClient -from integration_tests.test_framework.util import assert_raises_rpc_error -from integration_tests.test_framework.util.epoch import ( - epoch_invalid_epoch_type_error, - epoch_epoch_number_too_large_error, - epoch_empty_epoch_string_error, - epoch_invalid_digit_epoch_error, - epoch_missing_hex_prefix_error, -) - - -# If this errors is changed, please let me know https://github.com/Conflux-Chain/rpc-errors/issues/new -def test_get_epoch_number_errors(client: RpcClient): - assert_raises_rpc_error( - epoch_invalid_epoch_type_error.error_code, - epoch_invalid_epoch_type_error.error_msg, - client.epoch_number, - epoch_invalid_epoch_type_error.epoch, - ) - assert_raises_rpc_error( - epoch_epoch_number_too_large_error.error_code, - epoch_epoch_number_too_large_error.error_msg, - client.epoch_number, - epoch_epoch_number_too_large_error.epoch, - ) - assert_raises_rpc_error( - epoch_empty_epoch_string_error.error_code, - epoch_empty_epoch_string_error.error_msg, - client.epoch_number, - epoch_empty_epoch_string_error.epoch, - ) - assert_raises_rpc_error( - epoch_invalid_digit_epoch_error.error_code, - epoch_invalid_digit_epoch_error.error_msg, - client.epoch_number, - epoch_invalid_digit_epoch_error.epoch, - ) - - assert_raises_rpc_error( - epoch_missing_hex_prefix_error.error_code, - epoch_missing_hex_prefix_error.error_msg, - client.epoch_number, - epoch_missing_hex_prefix_error.epoch, - ) diff --git a/integration_tests/tests/rpc/test_get_tx_by_hash.py b/integration_tests/tests/rpc/test_get_tx_by_hash.py deleted file mode 100644 index 7d161f995d..0000000000 --- a/integration_tests/tests/rpc/test_get_tx_by_hash.py +++ /dev/null @@ -1,29 +0,0 @@ -from integration_tests.conflux.rpc import RpcClient -from integration_tests.test_framework.util import assert_raises_rpc_error, assert_equal - - -# If this errors is changed, please let me know https://github.com/Conflux-Chain/rpc-errors/issues/new - - -def test_get_tx_by_hash_errors(client: RpcClient): - - assert_raises_rpc_error( - -32602, - "Invalid params: invalid length 63, expected a (both 0x-prefixed or not) hex string with length of 64.", - client.node.cfx_getTransactionByHash, - "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944", - ) - - assert_raises_rpc_error( - -32602, - "Invalid params: invalid type: integer `11`, expected a (both 0x-prefixed or not) hex string with length of 64.", - client.node.cfx_getTransactionByHash, - 11, - ) - - assert_raises_rpc_error( - -32602, - "Invalid params: invalid length 0, expected a (both 0x-prefixed or not) hex string with length of 64.", - client.node.cfx_getTransactionByHash, - "0x", - ) diff --git a/tests/conflux/messages.py b/tests/conflux/messages.py index 31c485ed7b..963b543cd6 100644 --- a/tests/conflux/messages.py +++ b/tests/conflux/messages.py @@ -63,6 +63,7 @@ ) # Copied from rlp.sedes.Boolean, but encode False to 0x00, not empty. +# The current Conflux Rust implementation encodes False to 0x80 and treats both 0x00 and 0x80 as False. class Boolean: """A sedes for booleans """ @@ -78,13 +79,13 @@ def serialize(self, obj): raise Exception("Invariant: no other options for boolean values") def deserialize(self, serial): - if serial == b'\x00': + if serial == b'': return False elif serial == b'\x01': return True else: raise DeserializationError( - 'Invalid serialized boolean. Must be either 0x01 or 0x00', + 'Invalid serialized boolean. Must be either 0x01 or 0x80', serial ) diff --git a/tools/consensus_bench/Cargo.lock b/tools/consensus_bench/Cargo.lock index bc1e8efaea..a8651961f3 100644 --- a/tools/consensus_bench/Cargo.lock +++ b/tools/consensus_bench/Cargo.lock @@ -710,16 +710,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" -[[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" @@ -727,7 +717,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", - "radium 0.7.0", + "radium", "tap", "wyz", ] @@ -813,7 +803,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" dependencies = [ "blst", - "byte-slice-cast 1.2.2", + "byte-slice-cast", "ff", "group", "pairing", @@ -849,15 +839,9 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[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" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" +checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" [[package]] name = "byte-unit" @@ -983,7 +967,7 @@ version = "2.0.2" dependencies = [ "cfx-types", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "sqlite", "strfmt", "thiserror 2.0.11", @@ -1005,6 +989,7 @@ dependencies = [ "log", "pow-types", "primitives", + "rlp-bool", "solidity-abi", "typemap-ors", ] @@ -1033,7 +1018,7 @@ dependencies = [ "diem-types", "hex-literal 1.0.0", "impl-tools", - "impl-trait-for-tuples 0.2.2", + "impl-trait-for-tuples 0.2.3", "keccak-hash", "lazy_static", "log", @@ -1044,7 +1029,7 @@ dependencies = [ "pow-types", "primitives", "rayon", - "rlp 0.4.6", + "rlp 0.6.1", "rustc-hex", "sha3-macro", "solidity-abi", @@ -1067,7 +1052,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot 0.12.3", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -1124,7 +1109,8 @@ dependencies = [ "malloc_size_of", "malloc_size_of_derive", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "serde", "strum_macros", @@ -1148,7 +1134,7 @@ dependencies = [ "log", "parity-version", "primitives", - "rand 0.7.3", + "rand 0.8.5", "rustc-hex", "serde", "serde_derive", @@ -1172,7 +1158,7 @@ dependencies = [ "jsonrpc-core", "jsonrpsee", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "serde", "serde_json", "similar-asserts", @@ -1222,7 +1208,7 @@ dependencies = [ "log", "parking_lot 0.12.3", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "tiny-keccak", ] @@ -1256,7 +1242,8 @@ dependencies = [ "rand 0.9.0", "rand_chacha 0.9.0", "random-crash", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "rustc-hex", "serde", @@ -1284,7 +1271,7 @@ dependencies = [ "ethereum-types", "hex", "keccak-hash", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -1328,7 +1315,7 @@ dependencies = [ "cfx-types", "keccak-hash", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "serde", "solidity-abi", ] @@ -1344,6 +1331,7 @@ dependencies = [ "bls-signatures", "bounded-executor", "byteorder", + "bytes", "cached-pos-ledger-db", "cfx-addr", "cfx-bytes", @@ -1417,7 +1405,8 @@ dependencies = [ "rand_xorshift 0.4.0", "rangetools", "rayon", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "rustc-hex", "safety-rules", @@ -1477,7 +1466,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot 0.12.3", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "smart-default", "thiserror 2.0.11", @@ -1685,6 +1674,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_format" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -2511,12 +2520,12 @@ dependencies = [ [[package]] name = "ethbloom" -version = "0.9.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" +checksum = "8c321610643004cf908ec0f5f2aa0d8f1f8e14b540562a2887a1111ff1ecbf7b" dependencies = [ "crunchy", - "fixed-hash 0.6.1", + "fixed-hash", "impl-rlp", "impl-serde", "tiny-keccak", @@ -2530,16 +2539,16 @@ checksum = "e957efe1e627f8ec4e253660615fd9fe3736e10026197740b8b4b26c812be2e9" [[package]] name = "ethereum-types" -version = "0.9.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" +checksum = "1ab15ed80916029f878e0267c3a9f92b67df55e79af370bf66199059ae2b4ee3" dependencies = [ "ethbloom", - "fixed-hash 0.6.1", + "fixed-hash", "impl-rlp", "impl-serde", - "primitive-types 0.7.3", - "uint 0.8.5", + "primitive-types 0.13.1", + "uint 0.10.0", ] [[package]] @@ -2635,7 +2644,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "bitvec 1.0.1", + "bitvec", "rand_core 0.6.4", "subtle", ] @@ -2646,18 +2655,6 @@ version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93ace6ec7cc19c8ed33a32eaa9ea692d7faea05006b5356b9e2b668ec4bc3955" -[[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", - "static_assertions", -] - [[package]] name = "fixed-hash" version = "0.8.0" @@ -3477,36 +3474,36 @@ dependencies = [ [[package]] name = "impl-codec" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ - "parity-scale-codec 1.3.7", + "parity-scale-codec", ] [[package]] name = "impl-codec" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +checksum = "2d40b9d5e17727407e55028eafc22b2dc68781786e6d7eb8a21103f5058e3a14" dependencies = [ - "parity-scale-codec 3.6.9", + "parity-scale-codec", ] [[package]] name = "impl-rlp" -version = "0.2.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" +checksum = "54ed8ad1f3877f7e775b8cbf30ed1bd3209a95401817f19a0eb4402d13f8cf90" dependencies = [ - "rlp 0.4.6", + "rlp 0.6.1", ] [[package]] name = "impl-serde" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" dependencies = [ "serde", ] @@ -3548,13 +3545,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -3777,11 +3774,11 @@ dependencies = [ [[package]] name = "keccak-hash" -version = "0.5.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f58a51ef3df9398cf2434bea8d4eb61fb748d0feb1571f87388579a120a4c8f" +checksum = "3e1b8590eb6148af2ea2d75f38e7d29f5ca970d5a4df456b3ef19b8b415d0264" dependencies = [ - "primitive-types 0.7.3", + "primitive-types 0.13.1", "tiny-keccak", ] @@ -4298,7 +4295,7 @@ dependencies = [ "parking_lot 0.12.3", "priority-send-queue", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -4562,40 +4559,30 @@ dependencies = [ [[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-scale-codec" -version = "3.6.9" +version = "3.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "799781ae679d79a948e13d4824a40970bfa500058d245760dd857301059810fa" dependencies = [ "arrayvec 0.7.4", - "bitvec 1.0.1", - "byte-slice-cast 1.2.2", - "impl-trait-for-tuples 0.2.2", + "bitvec", + "byte-slice-cast", + "const_format", + "impl-trait-for-tuples 0.2.3", "parity-scale-codec-derive", + "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "34b4653168b563151153c9e4c08ebed57fb8262bebfa79711552fa983c623e7a" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -4999,26 +4986,26 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.7.3" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ - "fixed-hash 0.6.1", - "impl-codec 0.4.2", - "impl-rlp", - "impl-serde", - "uint 0.8.5", + "fixed-hash", + "impl-codec 0.6.0", + "uint 0.9.5", ] [[package]] name = "primitive-types" -version = "0.12.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" dependencies = [ - "fixed-hash 0.8.0", - "impl-codec 0.6.0", - "uint 0.9.5", + "fixed-hash", + "impl-codec 0.7.1", + "impl-rlp", + "impl-serde", + "uint 0.10.0", ] [[package]] @@ -5036,7 +5023,8 @@ dependencies = [ "malloc_size_of", "once_cell", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "serde", "serde_derive", @@ -5048,22 +5036,13 @@ dependencies = [ name = "priority-send-queue" version = "0.1.0" -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro-crate" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -5092,9 +5071,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -5157,9 +5136,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -5170,12 +5149,6 @@ version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" -[[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" @@ -5489,7 +5462,7 @@ dependencies = [ "alloy-primitives", "auto_impl", "bitflags 2.5.0", - "bitvec 1.0.1", + "bitvec", "c-kzg", "cfg-if 1.0.0", "derive_more 0.99.17", @@ -5539,23 +5512,33 @@ checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" [[package]] name = "rlp" -version = "0.4.6" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ + "bytes", "rustc-hex", ] [[package]] name = "rlp" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +checksum = "fa24e92bb2a83198bb76d661a71df9f7076b8c420b8696e4d3d97d50d94479e3" dependencies = [ "bytes", "rustc-hex", ] +[[package]] +name = "rlp-bool" +version = "3.0.0" +dependencies = [ + "malloc_size_of", + "malloc_size_of_derive", + "rlp 0.6.1", +] + [[package]] name = "rlp-derive" version = "0.2.0" @@ -5591,7 +5574,7 @@ dependencies = [ "num-bigint", "num-integer", "num-traits", - "parity-scale-codec 3.6.9", + "parity-scale-codec", "primitive-types 0.12.2", "proptest", "rand 0.8.5", @@ -5898,9 +5881,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] @@ -5946,9 +5929,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -6192,7 +6175,7 @@ dependencies = [ name = "solidity-abi-derive" version = "0.1.0" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -6656,7 +6639,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -6668,17 +6651,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap 2.8.0", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.20" @@ -6790,21 +6762,21 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" -version = "0.8.5" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", - "rustc-hex", + "hex", "static_assertions", ] [[package]] name = "uint" -version = "0.9.5" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" dependencies = [ "byteorder", "crunchy", @@ -7305,15 +7277,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "0.6.18" diff --git a/tools/evm-spec-tester/Cargo.lock b/tools/evm-spec-tester/Cargo.lock index e0c9ef186b..0df7003563 100644 --- a/tools/evm-spec-tester/Cargo.lock +++ b/tools/evm-spec-tester/Cargo.lock @@ -731,16 +731,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" -[[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" @@ -748,7 +738,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", - "radium 0.7.0", + "radium", "tap", "wyz", ] @@ -834,7 +824,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" dependencies = [ "blst", - "byte-slice-cast 1.2.2", + "byte-slice-cast", "ff", "group", "pairing", @@ -870,15 +860,9 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[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" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" +checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" [[package]] name = "byte-unit" @@ -1039,7 +1023,7 @@ version = "2.0.2" dependencies = [ "cfx-types", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "sqlite", "strfmt", "thiserror 2.0.11", @@ -1061,6 +1045,7 @@ dependencies = [ "log", "pow-types", "primitives", + "rlp-bool", "solidity-abi", "typemap-ors", ] @@ -1089,7 +1074,7 @@ dependencies = [ "diem-types", "hex-literal 1.0.0", "impl-tools", - "impl-trait-for-tuples 0.2.2", + "impl-trait-for-tuples 0.2.3", "keccak-hash", "lazy_static", "log", @@ -1100,7 +1085,7 @@ dependencies = [ "pow-types", "primitives", "rayon", - "rlp 0.4.6", + "rlp 0.6.1", "rustc-hex", "sha3-macro", "solidity-abi", @@ -1123,7 +1108,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot 0.12.1", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -1180,7 +1165,8 @@ dependencies = [ "malloc_size_of", "malloc_size_of_derive", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "serde", "strum_macros", @@ -1287,7 +1273,7 @@ dependencies = [ "log", "parity-version", "primitives", - "rand 0.7.3", + "rand 0.8.5", "rustc-hex", "serde", "serde_derive", @@ -1334,7 +1320,7 @@ dependencies = [ "jsonrpc-core", "jsonrpsee", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "serde", "serde_json", "similar-asserts", @@ -1404,7 +1390,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "tiny-keccak", ] @@ -1438,7 +1424,8 @@ dependencies = [ "rand 0.9.0", "rand_chacha 0.9.0", "random-crash", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "rustc-hex", "serde", @@ -1466,7 +1453,7 @@ dependencies = [ "ethereum-types", "hex", "keccak-hash", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -1510,7 +1497,7 @@ dependencies = [ "cfx-types", "keccak-hash", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "serde", "solidity-abi", ] @@ -1526,6 +1513,7 @@ dependencies = [ "bls-signatures", "bounded-executor", "byteorder", + "bytes", "cached-pos-ledger-db", "cfx-addr", "cfx-bytes", @@ -1599,7 +1587,8 @@ dependencies = [ "rand_xorshift 0.4.0", "rangetools", "rayon", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "rustc-hex", "safety-rules", @@ -1659,7 +1648,7 @@ dependencies = [ "malloc_size_of_derive", "parking_lot 0.12.1", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "smart-default", "thiserror 2.0.11", @@ -1897,6 +1886,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_format" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57c2eccfb16dbac1f4e61e206105db5820c9d26c3c472bc17c774259ef7744" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -2758,12 +2767,12 @@ dependencies = [ [[package]] name = "ethbloom" -version = "0.9.2" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" +checksum = "8c321610643004cf908ec0f5f2aa0d8f1f8e14b540562a2887a1111ff1ecbf7b" dependencies = [ "crunchy", - "fixed-hash 0.6.1", + "fixed-hash", "impl-rlp", "impl-serde", "tiny-keccak", @@ -2777,16 +2786,16 @@ checksum = "e957efe1e627f8ec4e253660615fd9fe3736e10026197740b8b4b26c812be2e9" [[package]] name = "ethereum-types" -version = "0.9.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" +checksum = "1ab15ed80916029f878e0267c3a9f92b67df55e79af370bf66199059ae2b4ee3" dependencies = [ "ethbloom", - "fixed-hash 0.6.1", + "fixed-hash", "impl-rlp", "impl-serde", - "primitive-types 0.7.3", - "uint 0.8.5", + "primitive-types 0.13.1", + "uint 0.10.0", ] [[package]] @@ -2811,7 +2820,7 @@ dependencies = [ "itertools 0.14.0", "log", "primitives", - "rlp 0.4.6", + "rlp 0.6.1", "serde_json", "structopt", "thiserror 2.0.11", @@ -2911,7 +2920,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ - "bitvec 1.0.1", + "bitvec", "rand_core 0.6.4", "subtle", ] @@ -2922,18 +2931,6 @@ version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93ace6ec7cc19c8ed33a32eaa9ea692d7faea05006b5356b9e2b668ec4bc3955" -[[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", - "static_assertions", -] - [[package]] name = "fixed-hash" version = "0.8.0" @@ -3824,36 +3821,36 @@ dependencies = [ [[package]] name = "impl-codec" -version = "0.4.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" dependencies = [ - "parity-scale-codec 1.3.7", + "parity-scale-codec", ] [[package]] name = "impl-codec" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +checksum = "2d40b9d5e17727407e55028eafc22b2dc68781786e6d7eb8a21103f5058e3a14" dependencies = [ - "parity-scale-codec 3.6.9", + "parity-scale-codec", ] [[package]] name = "impl-rlp" -version = "0.2.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" +checksum = "54ed8ad1f3877f7e775b8cbf30ed1bd3209a95401817f19a0eb4402d13f8cf90" dependencies = [ - "rlp 0.4.6", + "rlp 0.6.1", ] [[package]] name = "impl-serde" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +checksum = "4a143eada6a1ec4aefa5049037a26a6d597bfd64f8c026d07b77133e02b7dd0b" dependencies = [ "serde", ] @@ -3895,13 +3892,13 @@ dependencies = [ [[package]] name = "impl-trait-for-tuples" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -4189,7 +4186,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0d4c6bec4909c966f59f52db3655c0e9d4685faae8b49185973d9d7389bb884" dependencies = [ "heck 0.5.0", - "proc-macro-crate 3.2.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.96", @@ -4272,11 +4269,11 @@ dependencies = [ [[package]] name = "keccak-hash" -version = "0.5.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f58a51ef3df9398cf2434bea8d4eb61fb748d0feb1571f87388579a120a4c8f" +checksum = "3e1b8590eb6148af2ea2d75f38e7d29f5ca970d5a4df456b3ef19b8b415d0264" dependencies = [ - "primitive-types 0.7.3", + "primitive-types 0.13.1", "tiny-keccak", ] @@ -4802,7 +4799,7 @@ dependencies = [ "parking_lot 0.12.1", "priority-send-queue", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", "rlp-derive", "serde", "serde_derive", @@ -5066,40 +5063,30 @@ dependencies = [ [[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-scale-codec" -version = "3.6.9" +version = "3.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "799781ae679d79a948e13d4824a40970bfa500058d245760dd857301059810fa" dependencies = [ "arrayvec 0.7.4", - "bitvec 1.0.1", - "byte-slice-cast 1.2.2", - "impl-trait-for-tuples 0.2.2", + "bitvec", + "byte-slice-cast", + "const_format", + "impl-trait-for-tuples 0.2.3", "parity-scale-codec-derive", + "rustversion", "serde", ] [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "34b4653168b563151153c9e4c08ebed57fb8262bebfa79711552fa983c623e7a" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.96", ] [[package]] @@ -5503,26 +5490,26 @@ dependencies = [ [[package]] name = "primitive-types" -version = "0.7.3" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ - "fixed-hash 0.6.1", - "impl-codec 0.4.2", - "impl-rlp", - "impl-serde", - "uint 0.8.5", + "fixed-hash", + "impl-codec 0.6.0", + "uint 0.9.5", ] [[package]] name = "primitive-types" -version = "0.12.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +checksum = "d15600a7d856470b7d278b3fe0e311fe28c2526348549f8ef2ff7db3299c87f5" dependencies = [ - "fixed-hash 0.8.0", - "impl-codec 0.6.0", - "uint 0.9.5", + "fixed-hash", + "impl-codec 0.7.1", + "impl-rlp", + "impl-serde", + "uint 0.10.0", ] [[package]] @@ -5540,7 +5527,8 @@ dependencies = [ "malloc_size_of", "once_cell", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", + "rlp-bool", "rlp-derive", "serde", "serde_derive", @@ -5552,22 +5540,13 @@ dependencies = [ name = "priority-send-queue" version = "0.1.0" -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.2", -] - [[package]] name = "proc-macro-crate" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -5596,9 +5575,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -5661,9 +5640,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -5674,12 +5653,6 @@ version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" -[[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" @@ -6002,7 +5975,7 @@ dependencies = [ "alloy-primitives", "auto_impl", "bitflags 2.5.0", - "bitvec 1.0.1", + "bitvec", "c-kzg", "cfg-if 1.0.0", "derive_more 0.99.17", @@ -6066,23 +6039,33 @@ checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" [[package]] name = "rlp" -version = "0.4.6" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ + "bytes", "rustc-hex", ] [[package]] name = "rlp" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +checksum = "fa24e92bb2a83198bb76d661a71df9f7076b8c420b8696e4d3d97d50d94479e3" dependencies = [ "bytes", "rustc-hex", ] +[[package]] +name = "rlp-bool" +version = "3.0.0" +dependencies = [ + "malloc_size_of", + "malloc_size_of_derive", + "rlp 0.6.1", +] + [[package]] name = "rlp-derive" version = "0.2.0" @@ -6124,7 +6107,7 @@ dependencies = [ "num-bigint", "num-integer", "num-traits", - "parity-scale-codec 3.6.9", + "parity-scale-codec", "primitive-types 0.12.2", "proptest", "rand 0.8.5", @@ -6528,9 +6511,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] @@ -6576,9 +6559,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -6864,7 +6847,7 @@ dependencies = [ name = "solidity-abi-derive" version = "0.1.0" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 1.0.109", @@ -7400,7 +7383,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -7412,17 +7395,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap 2.8.0", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.20" @@ -7569,7 +7541,7 @@ dependencies = [ "parking_lot 0.12.1", "primitives", "rand 0.9.0", - "rlp 0.4.6", + "rlp 0.6.1", "rustc-hex", "secret-store", ] @@ -7597,21 +7569,21 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" -version = "0.8.5" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", - "rustc-hex", + "hex", "static_assertions", ] [[package]] name = "uint" -version = "0.9.5" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" dependencies = [ "byteorder", "crunchy", @@ -8146,15 +8118,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "0.6.18" diff --git a/tools/evm-spec-tester/Cargo.toml b/tools/evm-spec-tester/Cargo.toml index 32b1b3c74a..2a3791cdab 100644 --- a/tools/evm-spec-tester/Cargo.toml +++ b/tools/evm-spec-tester/Cargo.toml @@ -22,7 +22,7 @@ cfx-bytes = { path = "../../crates/cfx_bytes" } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } walkdir = "2.5" thiserror = "2.0.11" -rlp = "0.4.0" +rlp = "0.6.1" hex = "0.4.3" hex-literal = "0.4.1" diff --git a/tools/evm-spec-tester/src/statetest/unit_tester/post_transact.rs b/tools/evm-spec-tester/src/statetest/unit_tester/post_transact.rs index 4238096522..bf07ecc657 100644 --- a/tools/evm-spec-tester/src/statetest/unit_tester/post_transact.rs +++ b/tools/evm-spec-tester/src/statetest/unit_tester/post_transact.rs @@ -212,7 +212,7 @@ pub fn check_execution_outcome( // storage check for (&key, &value) in &account_info.storage { let mut key_bytes = [0u8; 32]; - key.to_big_endian(&mut key_bytes); + key.write_as_big_endian(&mut key_bytes); let curr_value = state.storage_at(&user_addr, &key_bytes).unwrap_or_default(); if curr_value != value { diff --git a/tools/evm-spec-tester/src/statetest/unit_tester/pre_transact.rs b/tools/evm-spec-tester/src/statetest/unit_tester/pre_transact.rs index 11139457a5..2e1257b2fd 100644 --- a/tools/evm-spec-tester/src/statetest/unit_tester/pre_transact.rs +++ b/tools/evm-spec-tester/src/statetest/unit_tester/pre_transact.rs @@ -27,11 +27,11 @@ use primitives::{ }, SignedTransaction, Transaction, }; +use rlp::Encodable; use std::{ collections::{BTreeMap, HashMap}, u64, }; - pub fn make_tx( tx_meta: &TransactionParts, tx_part_indices: &TxPartIndices, chain_id: u64, unprotected: bool, @@ -270,7 +270,7 @@ pub fn check_tx_bytes( return Ok(()); }; - let raw_tx = rlp::encode(&tx.transaction.transaction); + let raw_tx = &tx.transaction.transaction.rlp_bytes(); if raw_tx != txbytes { // trace!(