anza-xyz / anza-xyz/solana-sdk
`solana-secp256k1-program` is not buildable with `build-sbf`
- Langage dominant
- Rust
- Étoiles
- 256
- Forks
- 250
- Merge moyen
- 2 j 3 h
- PR mergées (30 j)
- 39
Description
Running `cargo build-sbf` in the `sec256k1-program` directory produces
```
error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
--> src/lib.rs:347:9
|
347 | / compile_error!("target is not supported, for more information see: \
348 | | https://docs.rs/getrandom/#unsupported-targets");
| |________________________________________________________________________^
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `imp`
--> src/lib.rs:398:9
|
398 | imp::getrandom_inner(dest)?;
| ^^^ use of unresolved module or unlinked crate `imp`
|
= help: if you wanted to use a crate named `imp`, use `cargo add imp` to add it to your `Cargo.toml
```
This is because by default, `k256` (which `sec256k1-program` depends on) pulls in `elliptic-curve` -> `rand_core` -> `getrandom`, and `getrandom` does not support BPF targets and will not compile.
The following patch allows it to compile by disabling this dep:
```diff,toml
diff --git a/Cargo.toml b/Cargo.toml
index 7914b658..25240162 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -182,7 +182,7 @@ im = "15.1.0"
indicatif = "0.17.9"
itertools = "0.12.1"
js-sys = "0.3.77"
-k256 = "0.13.0"
+k256 = { version = "0.13.0", default-features = false }
lazy_static = "1.5.0"
libc = "0.2.170"
light-poseidon = "0.4.0"
diff --git a/secp256k1-program/Cargo.toml b/secp256k1-program/Cargo.toml
index 79922b87..ae877603 100644
--- a/secp256k1-program/Cargo.toml
+++ b/secp256k1-program/Cargo.toml
@@ -27,7 +27,7 @@ serde = ["dep:serde", "dep:serde_derive"]
[dependencies]
bincode = { workspace = true, optional = true }
digest = { workspace = true }
-k256 = { workspace = true, features = ["ecdsa-core"] }
+k256 = { workspace = true, features = ["ecdsa"] }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
sha3 = { workspace = true }
```
However, this raises several errors due to functions with large stack usage, e.g
```
Error: A function call in method _ZN119_$LT$k256..arithmetic..affine..AffinePoint$u20$as$u20$core..ops..arith..Mul$LT$k256..arithmetic..scalar..Scalar$GT$$GT$3mul17had06096db359945dE overwrites values in the frame. Please, decrease stack usage or remove parameters from the call. The function call may cause undefined behavior during execution.
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.