parity-common
parity-common copied to clipboard
Use `array-bytes` for array/bytes/hex operations
Reasons: https://github.com/paritytech/substrate/issues/12111 Substrate PR: https://github.com/paritytech/substrate/pull/12190
Looks ok to me, but it is incomplete (good to merge once it passes CI)
Fixed. And it looks like there are some new errors in your CI script.
And I made some algorithm optimization these days.
Check the benchmark results here. https://github.com/hack-ink/array-bytes#benchmark-results
Not only it has blockchain-developer-friendly API.
I think it's also 1.2x ~ 4x
faster than the hex crate.
Hi! Any plan for this?
Can you resolve the merge conflict? @ordian wanna also take a look?
I've taken a look before and remained unconvinced.
One of the benefits advertized:
And it's completely no-std.
We could also use
rustc-hex
without it'sstd
feature and call it completely no-std this way.By switfly looking at https://github.com/hack-ink/array-bytes/blob/main/src/lib.rs I see a few problems:
- It's using unidiomatic function naming: https://rust-lang.github.io/api-guidelines/naming.html
- Unwraps and safe
unchecked
methods.- It's not audited.
So what's the benefit, really?
- IMHO, the API is much easier to understand:
x2y
. - It did provide some
unchecked
functions, but to use it, it's totally up to you. Maybe you are writing some off-chain tools or unit tests, then you might want to get rid of theResult
. - True. But I'd love to push this.
- It has fuzzy tests.
- It was used by Substrate.
- It's faster than rust-hex.
- It handles the
0x
prefix. - And it provides some
*_into
functions which are pretty convenient/handy for Substrate/blockchain development. - Also, some
serde
support.
For me, I want to bring these to other blockchain developers.
It's really an honor and a good example to be a part of the parity-common (one of the most frequently used blockchain library).
Would you consider this?