Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Use array-bytes for All Array/Bytes/Hex Operations
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier committed Sep 5, 2022
1 parent 41b6b38 commit 4527bd6
Show file tree
Hide file tree
Showing 45 changed files with 190 additions and 164 deletions.
37 changes: 21 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bin/node-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false
pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" }

# Used for runtime benchmarking
array-bytes = { version = "4.0", optional = true }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking", optional = true }
frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
hex-literal = { version = "0.3.4", optional = true }

# Local Dependencies
pallet-template = { version = "4.0.0-dev", default-features = false, path = "../pallets/template" }
Expand Down Expand Up @@ -90,7 +90,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system-benchmarking",
"frame-system/runtime-benchmarks",
"hex-literal",
"array-bytes",
"pallet-balances/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-template/runtime-benchmarks",
Expand Down
10 changes: 5 additions & 5 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,15 @@ impl_runtime_apis! {

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"),
// Total Issuance
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
array_bytes::hex_into_unchecked("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"),
// Execution Phase
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a"),
// Event Count
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"),
// System Events
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7"),
];

let mut batches = Vec::<BenchmarkBatch>::new();
Expand Down
2 changes: 1 addition & 1 deletion bin/node/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
array-bytes = "4.0"
clap = { version = "3.1.18", features = ["derive"] }
log = "0.4.17"
node-primitives = { version = "2.0.0", path = "../primitives" }
Expand All @@ -32,7 +33,6 @@ sp-tracing = { version = "5.0.0", path = "../../../primitives/tracing" }
hash-db = "0.15.2"
tempfile = "3.1.0"
fs_extra = "1"
hex = "0.4.0"
rand = { version = "0.7.2", features = ["small_rng"] }
lazy_static = "1.4.0"
parity-util-mem = { version = "0.11.0", default-features = false, features = ["primitive-types"] }
Expand Down
6 changes: 4 additions & 2 deletions bin/node/bench/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ pub fn generate_trie(
let (db, overlay) = {
let mut overlay = HashMap::new();
overlay.insert(
hex::decode("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314")
.expect("null key is valid"),
array_bytes::hex2bytes(
"03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314",
)
.expect("null key is valid"),
Some(vec![0]),
);
let mut trie = SimpleTrie { db, overlay: &mut overlay };
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
# third-party dependencies
array-bytes = "4.0"
clap = { version = "3.1.18", features = ["derive"], optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.136", features = ["derive"] }
jsonrpsee = { version = "0.15.1", features = ["server"] }
futures = "0.3.21"
hex-literal = "0.3.4"
log = "0.4.17"
rand = "0.8"

Expand Down
Loading

0 comments on commit 4527bd6

Please sign in to comment.