Skip to content

Commit e20ab63

Browse files
committed
chore: update rlp dependency to fork with legacy boolean encoding support
1 parent c773ce8 commit e20ab63

File tree

7 files changed

+42
-13
lines changed

7 files changed

+42
-13
lines changed

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ proc-macro-crate = "3"
264264
serde = { version = "1.0", features = [
265265
"derive",
266266
"alloc",
267-
"rc"
267+
"rc",
268268
], default-features = false }
269269
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
270270
serde_derive = { version = "1.0", default-features = false }
@@ -381,7 +381,7 @@ vergen = "8.3.2"
381381
target_info = "0.1"
382382
bit-set = "0.4"
383383
typenum = "1.17.0"
384-
typemap = { package = "typemap-ors", version = "1.0"}
384+
typemap = { package = "typemap-ors", version = "1.0" }
385385
impl-trait-for-tuples = "^0.2"
386386
impl-tools = "^0.10"
387387
derive_more = "0.99"
@@ -424,7 +424,10 @@ chrono = "0.4"
424424
duration-str = "0.17"
425425

426426
# parity crates
427-
rlp = "0.6.1"
427+
# The fork of the rlp crate adds a legacy v0.4.x boolean encoding to the v0.6.x
428+
rlp = { git = "https://github.com/Conflux-Chain/parity-common-rocksdb.git", rev = "b28832745c952c8bcac88348276b283c26de776a", package = "rlp", features = [
429+
"legacy_bool_encoding",
430+
] }
428431
rlp_derive = { package = "rlp-derive", version = "0.2.0" }
429432
panic_hook = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "09da4dfeecd754df2034d4e71a260277aaaf9783" }
430433
dir = { git = "https://github.com/Conflux-Chain/conflux-parity-deps.git", rev = "09da4dfeecd754df2034d4e71a260277aaaf9783" }
@@ -455,3 +458,6 @@ rocksdb = { git = "https://github.com/Conflux-Chain/rust-rocksdb.git", rev = "7d
455458

456459
[patch.crates-io]
457460
sqlite3-sys = { git = "https://github.com/Conflux-Chain/sqlite3-sys.git", rev = "1de8e5998f7c2d919336660b8ef4e8f52ac43844" }
461+
rlp = { git = "https://github.com/Conflux-Chain/parity-common-rocksdb.git", rev = "b28832745c952c8bcac88348276b283c26de776a", package = "rlp", features = [
462+
"legacy_bool_encoding",
463+
] }

crates/cfx_types/src/utils.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,23 @@ pub fn u256_to_h256_be(value: U256) -> H256 {
4242
pub fn h256_to_u256_be(value: H256) -> U256 {
4343
U256::from_big_endian(value.as_bytes())
4444
}
45+
46+
#[cfg(test)]
47+
mod tests {
48+
use hex;
49+
#[test]
50+
fn test_legacy_bool_encode() {
51+
// by now we need use the legacy bool encoding
52+
// which is 0x00 for false and 0x01 for true
53+
// the newer encoding is 0x80 for false and 0x01 for true
54+
55+
let false_bytes = hex::decode("00").unwrap();
56+
let true_bytes = hex::decode("01").unwrap();
57+
58+
assert_eq!(rlp::encode(&false).as_ref(), false_bytes);
59+
assert_eq!(rlp::encode(&true).as_ref(), true_bytes);
60+
61+
assert_eq!(rlp::decode::<bool>(&false_bytes), Ok(false));
62+
assert_eq!(rlp::decode::<bool>(&true_bytes), Ok(true));
63+
}
64+
}

tools/consensus_bench/Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/consensus_bench/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ threadpool = "1.7"
1515
parking_lot = "0.12"
1616
log4rs = { version = "1.3.0", features = ["background_rotation", "gzip"] }
1717
log = "0.4"
18+
19+
[patch.crates-io]
20+
rlp = { git = "https://github.com/Conflux-Chain/parity-common-rocksdb.git", rev = "b28832745c952c8bcac88348276b283c26de776a", package = "rlp" }

tools/evm-spec-tester/Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/evm-spec-tester/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ clap = { version = "4.5", features = ["derive"] }
3535
clap-verbosity-flag = "3"
3636

3737
[features]
38-
default = ["cfx-executor/align_evm", "cfx-statedb/testonly_code"]
38+
default = ["cfx-executor/align_evm", "cfx-statedb/testonly_code"]
39+
40+
[patch.crates-io]
41+
rlp = { git = "https://github.com/Conflux-Chain/parity-common-rocksdb.git", rev = "b28832745c952c8bcac88348276b283c26de776a", package = "rlp" }

0 commit comments

Comments
 (0)