Upgrade fixed-hash
sgkim126 opened this issue · 10 comments
Currently, CodeChain uses fixed-hash@0.2.1 that has a duplicated macro definition.
The duplicated macro makes the latest clippy fail, so we should upgrade it to 0.2.5.
You can read https://doc.rust-lang.org/cargo/commands/cargo-update.html to find how to do it.
@sgkim126 I want to solve this issue, but didn't fully understand the problem. Could you explain the problem in detail?
I updated clippy to the latest version and ran it.
This following:
rustup toolchain install nightly-2019-12-19
rustup component add clippy --toolchain nightly-2019-12-19
cargo +nightly-2019-12-19 clippy --all --all-targets
And the following errors were found:
error: a macro named `impl_heapsize_for_hash` has already been exported
--> /Users/somniumism/.cargo/registry/src/github.com-1ecc6299db9ec823/fixed-hash-0.2.1/src/hash.rs:431:1
|
431 | / macro_rules! impl_heapsize_for_hash {
432 | | ($name: ident) => {
433 | | impl $crate::heapsize::HeapSizeOf for $name {
434 | | fn heap_size_of_children(&self) -> usize {
... |
438 | | }
439 | | }
| |_^ `impl_heapsize_for_hash` already exported
|
note: previous macro export is now shadowed
--> /Users/somniumism/.cargo/registry/src/github.com-1ecc6299db9ec823/fixed-hash-0.2.1/src/hash.rs:325:1
|
325 | / macro_rules! impl_heapsize_for_hash {
326 | | ($name: ident) => {
327 | | impl $crate::heapsize::HeapSizeOf for $name {
328 | | fn heap_size_of_children(&self) -> usize {
... |
332 | | }
333 | | }
| |_^
As you said, I thought an error occurred because package fixed-hash is version 0.2.1, and I updated it to 0.2.5
This following:
cargo update -p fixed-hash --precise 0.2.5
cargo build
And the following warnings were found:
warning: use of deprecated item 'primitives::H256::from_slice': unconventional API, replaced by `new_from_slice` in version 0.3
--> core/src/blockchain/blockchain.rs:61:23
|
61 | Some(hash) => H256::from_slice(&hash).into(),
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
And ran clippy, the following too many warnings were found:
warning: use of deprecated item 'primitives::H256::from_slice': unconventional API, replaced by `new_from_slice` in version 0.3
--> key/src/ecdsa.rs:72:9
|
72 | H256::from_slice(self.s()) <= "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0".into()
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
.
.
.
warning: use of deprecated item 'ethereum_types::hash::H160::low_u64': will be renamed to `low_u64_be` in version 0.3
--> keystore/src/accounts_dir/memory.rs:72:24
|
72 | val ^= acc.low_u64()
| ^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
from_slice is deprecated. As the compiler said, you should replace from_slice to new_from_slice and low_u64 to low_u64_be.
I've already tried it. Sorry for the late update due to attending the seminar.
I replaced from_slice to new_from_slice, and find following errors.
error[E0599]: no function or associated item named `new_from_slice` found for type `primitives::H256` in the current scope
--> core/src/blockchain/blockchain.rs:61:29
|
61 | Some(hash) => H256::new_from_slice(&hash).into(),
| ^^^^^^^^^^^^^^
| |
| function or associated item not found in `primitives::H256`
| help: there is a method with a similar name: `clone_from_slice`
To solve this error, I will try some things. If you have any advice, I'd appreciate it.
It seems that fixed-hash didn't provide the new methods and just added deprecation warnings.
There are two ways.
- Update rust-codechain-primitives that uses fixed-hash to make it use later than 0.3 of fixed-hash.
- Update fixed-hash to 0.2.2 instead of 0.2.5. I checked 0.2.2 had resolved the macro duplication problem.
@sgkim126 I think the first way is better for this project because it can use in later versions than now(0.2.5 or 0.3.0) in the future. Am I right? So I want to try the first way, could you explain the things that have to update?
- Upgrade primitives to use the upgraded fixed-hash.
- Upgrade libraries using
primitivesused by CodeChain and modules in CodeChain.
You can see the libraries and modules using primitives in Cargo.lock.
I suggest that you do the second way if you are not familiar with the lock file.
@sgkim126 I tried to upgrade primitives to use the upgraded fixed-hash. I updated ethereum-types = "0.4.0" to ethereum-types = "0.5.2", ethbloom = "0.5.0" to ethbloom = "0.6.4", and ethereum-types-serialized to 0.2.2 etc. However, their previous version still remain within Cargo.lock, because too many libraries(rlp, rust-codechain-crypto etc) are using primitives is not updated; So there is a conflict between them. This is not a problem that will be solved just by upgrading primitives. I think we need a large-scale update to use fixed-hash@≥0.2.5 and later version of some packages.
I think it's best to upgrade fixed-hash@0.2.1 to 0.2.2 under the current situation. I want to know what you think.
@somniumism I agree.