Skip to content

Fix for cargo install fail.#157

Merged
philippem merged 1 commit intoBlockstream:new-indexfrom
rem1-dev:rpc-anonymization-refactor
Jul 16, 2025
Merged

Fix for cargo install fail.#157
philippem merged 1 commit intoBlockstream:new-indexfrom
rem1-dev:rpc-anonymization-refactor

Conversation

@rem1-dev
Copy link

@rem1-dev rem1-dev commented Jul 12, 2025

Fix for cargo install fail. random function was not re-exported by bitcoin::secp256k1::rand even though rand feature was enabled in bitcoin crate and resulted in following error:

#13 69.51 warning: unused import: `electrum_client::Error as ElectrumError`
#13 69.51  --> src/electrum/client.rs:6:9
#13 69.51   |
#13 69.51 6 | pub use electrum_client::Error as ElectrumError;
#13 69.51   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 69.51   |
#13 69.51   = note: `#[warn(unused_imports)]` on by default
#13 69.51 
#13 70.47 warning: field `added_by` is never read
#13 70.47   --> src/electrum/discovery.rs:83:5
#13 70.47    |
#13 70.47 78 | struct HealthCheck {
#13 70.47    |        ----------- field in this struct
#13 70.47 ...
#13 70.47 83 |     added_by: Option<IpAddr>,
#13 70.47    |     ^^^^^^^^
#13 70.47    |
#13 70.47    = note: `HealthCheck` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
#13 70.47    = note: `#[warn(dead_code)]` on by default
#13 70.47 
#13 89.92 warning: `electrs` (lib) generated 2 warnings (run `cargo fix --lib -p electrs` to apply 1 suggestion)
#13 89.99 error[E0425]: cannot find function `random` in crate `rand`
#13 89.99    --> src/bin/electrs.rs:164:40
#13 89.99     |
#13 89.99 164 |     let random_bytes: [u8; 32] = rand::random();
#13 89.99     |                                        ^^^^^^ not found in `rand`
#13 89.99     |
#13 89.99 note: found an item that was configured out
#13 89.99    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/lib.rs:183:8
#13 89.99     |
#13 89.99 183 | pub fn random<T>() -> T
#13 89.99     |        ^^^^^^
#13 89.99 
#13 90.00 warning: unused import: `bitcoin::hex::DisplayHex`
#13 90.00   --> src/bin/electrs.rs:12:5
#13 90.00    |
#13 90.00 12 | use bitcoin::hex::DisplayHex;
#13 90.00    |     ^^^^^^^^^^^^^^^^^^^^^^^^
#13 90.00    |
#13 90.00    = note: `#[warn(unused_imports)]` on by default
#13 90.00 
#13 90.00 For more information about this error, try `rustc --explain E0425`.
#13 90.01 warning: `electrs` (bin "electrs") generated 1 warning
#13 90.01 error: could not compile `electrs` (bin "electrs") due to previous error; 1 warning emitted
#13 90.01 warning: build failed, waiting for other jobs to finish...
#13 114.2 error: failed to compile `electrs v0.4.1 (/app/electrs)`

but only during cargo install run! command to reproduce: cargo install --jobs $(nproc) --root /app/electrs_bitcoin --locked --path . --features electrum-discovery . It'e reproducible also local (not only on CI)

The fix is to introduce rand crate and use its rng for random bytes generations. The project already depends on rand crate indirectly through bitcoin::secp256k1 when bitcoin rand feature is enabled (see cargo tree -e features).

…in::secp256k1::rand even thought rand feature was enabled in bitcoin crate
@rem1-dev rem1-dev force-pushed the rpc-anonymization-refactor branch from 0a24fd0 to cf7c75c Compare July 15, 2025 19:20
@rem1-dev rem1-dev changed the title Make sure ip anonymization code uess rand through bitcoin::secp256k1::rand Fix for cargo install fail. Jul 15, 2025
@rem1-dev
Copy link
Author

@RCasatta please review

@philippem philippem merged commit d314e02 into Blockstream:new-index Jul 16, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants