solana-labs / solana-program-library

A collection of Solana programs maintained by Solana Labs
https://solanalabs.com
Apache License 2.0
3.6k stars 2.1k forks source link

`spl-token-2022@6.0.0` can't build in `wasm` environment #7478

Closed ifiokjr closed 15 hours ago

ifiokjr commented 2 weeks ago

Description

spl-token-2022 can't be built in a wasm32 environment in version 5 and 6.

Running this command:

cargo build --package spl-token-2022@6.0.0 --target wasm32-unknown-unknown

Produces the following error:

solana-program-library on  master [!] via ⬢ v22.8.0 via 🦀 1.82.0
➜ cargo build --package spl-token-2022@6.0.0 --target wasm32-unknown-unknown
   Compiling serde v1.0.214
   Compiling ahash v0.8.11
   Compiling zeroize v1.8.1
   Compiling scopeguard v1.2.0
   Compiling smallvec v1.13.2
   Compiling bytemuck v1.19.0
   Compiling bs58 v0.5.1
   Compiling rand v0.8.5
   Compiling rand v0.7.3
   Compiling num-traits v0.2.19
   Compiling crunchy v0.2.2
   Compiling lock_api v0.4.11
   Compiling cc v1.1.31
   Compiling parking_lot_core v0.9.9
   Compiling log v0.4.22
   Compiling web-sys v0.3.55
   Compiling itertools v0.10.5
   Compiling parking_lot v0.12.0
   Compiling memchr v2.6.4
   Compiling solana-atomic-u64 v2.1.0
   Compiling ark-std v0.4.0
   Compiling chrono v0.4.38
   Compiling merlin v3.0.0
   Compiling console_log v0.2.2
   Compiling spl-discriminator-syn v0.2.0 (/Developer/os/solana-program-library/libraries/discriminator/syn)
   Compiling spl-program-error-derive v0.4.1 (/Developer/os/solana-program-library/libraries/program-error/derive)
   Compiling solana-security-txt v1.1.1
   Compiling spl-discriminator-derive v0.2.0 (/Developer/os/solana-program-library/libraries/discriminator/derive)
   Compiling blake3 v1.5.4
   Compiling hashbrown v0.13.2
   Compiling generic-array v0.14.7
   Compiling solana-hash v2.1.0
   Compiling bincode v1.3.3
   Compiling bitflags v2.6.0
   Compiling solana-clock v2.1.0
   Compiling bv v0.11.1
   Compiling solana-epoch-schedule v2.1.0
   Compiling solana-last-restart-slot v2.1.0
   Compiling solana-serde-varint v2.1.0
   Compiling solana-short-vec v2.1.0
   Compiling serde_bytes v0.11.15
   Compiling solana-fee-calculator v2.1.0
   Compiling solana-rent v2.1.0
   Compiling serde_with v3.11.0
   Compiling solana-slot-hashes v2.1.0
   Compiling solana-inflation v2.1.0
   Compiling serde_json v1.0.132
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling digest v0.9.0
   Compiling block-buffer v0.9.0
   Compiling crypto-mac v0.8.0
   Compiling inout v0.1.3
   Compiling hmac v0.8.1
   Compiling digest v0.10.7
   Compiling sha2 v0.9.9
   Compiling libsecp256k1-core v0.2.2
   Compiling solana-slot-history v2.1.0
   Compiling curve25519-dalek v3.2.0
   Compiling hmac-drbg v0.3.0
   Compiling num-integer v0.1.46
   Compiling sha2 v0.10.8
   Compiling curve25519-dalek v4.1.3
   Compiling ark-serialize v0.4.2
   Compiling sha3 v0.10.8
   Compiling cipher v0.4.4
   Compiling solana-sha256-hasher v2.1.0
   Compiling num-bigint v0.4.6
   Compiling hmac v0.12.1
   Compiling universal-hash v0.5.1
   Compiling aes v0.8.4
   Compiling polyval v0.6.2
   Compiling ctr v0.9.2
   Compiling libsecp256k1 v0.6.0
   Compiling ed25519-dalek v1.0.1
   Compiling solana-signature v2.1.0
   Compiling ed25519-dalek-bip32 v0.2.0
   Compiling pbkdf2 v0.11.0
   Compiling solana-packet v2.1.0
   Compiling aead v0.5.2
   Compiling solana-curve25519 v2.1.0
   Compiling aes-gcm-siv v0.11.1
   Compiling ark-ff-macros v0.4.2
   Compiling toml v0.5.8
   Compiling ark-ff v0.4.2
   Compiling proc-macro-crate v0.1.5
   Compiling borsh-derive v0.10.3
   Compiling solana-secp256k1-recover v2.1.0
   Compiling borsh v0.10.3
   Compiling solana-pubkey v2.1.0
   Compiling solana-borsh v2.1.0
   Compiling solana-instruction v2.1.0
   Compiling solana-feature-set v2.1.0
   Compiling solana-program-error v2.1.0
   Compiling solana-stable-layout v2.1.0
   Compiling solana-transaction-error v2.1.0
   Compiling solana-serialize-utils v2.1.0
   Compiling solana-bincode v2.1.0
   Compiling solana-account-info v2.1.0
   Compiling solana-program-pack v2.1.0
   Compiling spl-discriminator v0.4.0 (/Developer/os/solana-program-library/libraries/discriminator)
   Compiling solana-program-entrypoint v2.1.0
   Compiling solana-cpi v2.1.0
   Compiling solana-program v2.1.0
   Compiling spl-memo v6.0.0 (/Developer/os/solana-program-library/memo/program)
   Compiling ark-poly v0.4.2
   Compiling ark-ec v0.4.2
   Compiling solana-account v2.1.0
   Compiling spl-program-error v0.6.0 (/Developer/os/solana-program-library/libraries/program-error)
   Compiling spl-token v7.0.0 (/Developer/os/solana-program-library/token/program)
   Compiling ark-bn254 v0.4.0
   Compiling solana-bn254 v2.1.0
   Compiling solana-sdk v2.1.0
   Compiling solana-zk-sdk v2.1.0
   Compiling spl-pod v0.5.0 (/Developer/os/solana-program-library/libraries/pod)
   Compiling spl-token-confidential-transfer-ciphertext-arithmetic v0.2.0 (/Developer/os/solana-program-library/token/confidential-transfer/ciphertext-arithmetic)
   Compiling spl-token-confidential-transfer-proof-generation v0.2.0 (/Developer/os/solana-program-library/token/confidential-transfer/proof-generation)
error[E0433]: failed to resolve: could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
  --> token/confidential-transfer/proof-generation/src/burn.rs:12:9
   |
12 |         zk_elgamal_proof_program::proof_data::{
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
   |
note: found an item that was configured out
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:29:9
   |
29 | pub mod zk_elgamal_proof_program;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:28:1
   |
28 | #[cfg(not(target_arch = "wasm32"))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
  --> token/confidential-transfer/proof-generation/src/errors.rs:1:21
   |
1  | use {solana_zk_sdk::zk_elgamal_proof_program::errors::ProofGenerationError, thiserror::Error};
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^ could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
   |
note: found an item that was configured out
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:29:9
   |
29 | pub mod zk_elgamal_proof_program;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:28:1
   |
28 | #[cfg(not(target_arch = "wasm32"))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
  --> token/confidential-transfer/proof-generation/src/mint.rs:12:9
   |
12 |         zk_elgamal_proof_program::proof_data::{
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
   |
note: found an item that was configured out
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:29:9
   |
29 | pub mod zk_elgamal_proof_program;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:28:1
   |
28 | #[cfg(not(target_arch = "wasm32"))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
  --> token/confidential-transfer/proof-generation/src/transfer.rs:13:9
   |
13 |         zk_elgamal_proof_program::proof_data::{
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
   |
note: found an item that was configured out
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:29:9
   |
29 | pub mod zk_elgamal_proof_program;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:28:1
   |
28 | #[cfg(not(target_arch = "wasm32"))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
  --> token/confidential-transfer/proof-generation/src/transfer_with_fee.rs:16:9
   |
16 |         zk_elgamal_proof_program::proof_data::{
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
   |
note: found an item that was configured out
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:29:9
   |
29 | pub mod zk_elgamal_proof_program;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:28:1
   |
28 | #[cfg(not(target_arch = "wasm32"))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
  --> token/confidential-transfer/proof-generation/src/withdraw.rs:8:9
   |
8  |         zk_elgamal_proof_program::proof_data::{
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ could not find `zk_elgamal_proof_program` in `solana_zk_sdk`
   |
note: found an item that was configured out
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:29:9
   |
29 | pub mod zk_elgamal_proof_program;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^
note: the item is gated here
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-zk-sdk-2.1.0/src/lib.rs:28:1
   |
28 | #[cfg(not(target_arch = "wasm32"))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0433`.
error: could not compile `spl-token-confidential-transfer-proof-generation` (lib) due to 6 previous errors
warning: build failed, waiting for other jobs to finish...

solana-program-library on  master [!] via ⬢ v22.8.0 via 🦀 1.82.0 took 13.0s

However, running the following:

cargo build --package spl-token-2022@4.0.0 --target wasm32-unknown-unknown

Compiles with no errors.

This is preventing my upgrade to v2 (https://github.com/ifiokjr/wasm_solana/pull/20) in wasm_client_solana. Browser tests fail to compile since the target is wasm32-unknown-unknown.

joncinque commented 2 weeks ago

@samkim-crypto can you look into this one?

ifiokjr commented 15 hours ago

This is now fixed when using solana-*@2.1.2.

Thanks!