Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: how to compile wasm-dpp with debug logs #8

Open
coolaj86 opened this issue Feb 15, 2025 · 1 comment
Open

doc: how to compile wasm-dpp with debug logs #8

coolaj86 opened this issue Feb 15, 2025 · 1 comment

Comments

@coolaj86
Copy link
Member

coolaj86 commented Feb 15, 2025

Requirements

  • 4GB of RAM worked for me
  • 5GB of space for compiling (probably more with temp files)
    2.6G    /home/app/.rustup
    1.9G    /home/app/platform
    

Process

  1. Update to UTF-8 (for yarn animations and such)
    sudo locale-gen en_US.UTF-8
    sudo update-locale LANGE=en_US.UTF-8
  2. Install various C++ and llvm build tools (not sure why)
    (the build-essential meta package is probably overkill, but I didn't want to deal with each)
    sudo apt-get install -y build-essential libssl-dev pkg-config clang cmake llvm
    # OR
    # apk add alpine-sdk
  3. Install Node @ v22 (current LTS) and Rust
    curl https://webi.sh/node@v22 | sh
    curl https://webi.sh/rust | sh
    
    source ~/.config/envman/PATH.env
  4. Clone and build wasm-dpp
    git clone --depth=1 --branch=master https://github.com/dashevo/platform
    cd ./platform/packages/wasm-dpp/
    
    # may "hang" for minutes before first output
    # IMPORTANT: the necessary version may change
    cargo install -f wasm-bindgen-cli --version 0.2.99
    corepack enable
    yarn install --immutable
    yarn build
  5. TODO how to use it???
  6. ./platform/packages/dapi-grpc/protos/platform/v0/platform.proto

Versions

cat /etc/issue

Ubuntu 24.04 LTS \n \l
node --version

v22.14.0
cargo --version

cargo 1.83.0 (5ffbef321 2024-10-29)
rustc --version

rustc 1.83.0 (90b35a623 2024-11-26)
pkg-config --version

1.8.1
cmake --version
cmake version 3.28.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
clang --version

Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
make --version

GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
gcc --version

gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@coolaj86
Copy link
Member Author

coolaj86 commented Feb 16, 2025

Fixing Corrupt Corepack

If you run the wrong corepack command - or even the right corepack command with a misconfigured package.json, it can royally screw up your node config and cause unrelated things to fail. Here's how I fixed it:

rm -rf ~/.local/opt/node*
rm -rf ~/platform/
rm -rf ~/.cache/node*
rm -rf ~/.npm/
rm -rf ~/.yarn/
rm ~/.pnp.cjs

Errors (fixed, see above)

When corepack use yarn is run on a misconfigured package.json.

➤ YN0000: · Yarn 4.0.1
➤ YN0000: ┌ Project validation
➤ YN0057: │ dashmate: Resolutions field will be ignored
➤ YN0000: └ Completed
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0s 711ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ No new packages added to the project, but one was removed (- 23.19 KiB).
➤ YN0000: └ Completed in 0s 902ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ @dashevo/protobufjs@npm:6.10.5 must be built because it never has been before or the last one failed
➤ YN0007: │ protobufjs@npm:6.11.4 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:3.33.2 must be built because it never has been before or the last one failed
➤ YN0007: │ ssh2@npm:1.11.0 must be built because it never has been before or the last one failed
➤ YN0007: │ @pshenmic/zeromq@npm:6.0.0-beta.22 must be built because it never has been before or the last one failed
➤ YN0007: │ diskusage@npm:1.2.0 must be built because it never has been before or the last one failed
➤ YN0007: │ bufferutil@npm:4.0.6 must be built because it never has been before or the last one failed
➤ YN0007: │ utf-8-validate@npm:5.0.9 must be built because it never has been before or the last one failed
➤ YN0009: │ diskusage@npm:1.2.0 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-58cd4a6a/build.log)
➤ YN0000: └ Completed in 12s 252ms
➤ YN0000: · Failed with errors in 14s 409ms

When corepack is corrupt.

/home/app/platform/.pnp.cjs:26118
      Error.captureStackTrace(firstError);
            ^

Error: Your application tried to access corepack, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: corepack (via "corepack/package.json")
Required by: /home/app/.local/opt/node-v22.14.0/lib/node_modules/corepack/dist/lib/

Require stack:
- /home/app/.local/opt/node-v22.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs
- /home/app/.local/opt/node-v22.14.0/lib/node_modules/corepack/dist/yarn.js
    at require$$0.Module._resolveFilename (/home/app/platform/.pnp.cjs:26118:13)
    at Function.resolve (node:internal/modules/helpers:146:19)
    at runVersion (/home/app/.local/opt/node-v22.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs:21980:68)
    at Engine.executePackageManagerRequest (/home/app/.local/opt/node-v22.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs:22424:18)
    at async Object.runMain (/home/app/.local/opt/node-v22.14.0/lib/node_modules/corepack/dist/lib/corepack.cjs:23110:7)

Node.js v22.14.0

Rust tools

When the Rust tools aren't installed.

+ TARGET=wasm32-unknown-unknown
+ CARGO_BUILD_PROFILE=dev
+ PROFILE_ARG='--profile dev'
+ PROFILE=dev
+ [[ dev == \d\e\v ]]
+ PROFILE=debug
+ OUTPUT_DIR=/home/app/platform/packages/wasm-dpp/wasm
+ OUTPUT_FILE=/home/app/platform/packages/wasm-dpp/wasm/wasm_dpp_bg.wasm
+ BUILD_COMMAND='cargo build --config net.git-fetch-with-cli=true --target=wasm32-unknown-unknown --profile dev'
+ BINDGEN_COMMAND='wasm-bindgen --out-dir=/home/app/platform/packages/wasm-dpp/wasm --target=web --omit-default-module-path ../../target/wasm32-unknown-unknown/debug/wasm_dpp.wasm'
+ [[ -d /home/app/platform/packages/wasm-dpp/wasm ]]
+ mkdir -p /home/app/platform/packages/wasm-dpp/wasm
++ command -v wasm-bindgen
+ [[ -x '' ]]
+ echo 'Wasm-bindgen CLI  is not installed.'
Wasm-bindgen CLI  is not installed.
+ exit 1

My Discovery Process

How I found out where node, yarn, corepack, pnp, and other files were hiding:

# install lsd
curl https://webi.sh/lsd | sh

# check 
lsd --tree -A -I node_modules -I .vim -I 'node-*' -I '.rustup' -I 'generated_completions' -I Downloads -I Documents -I Desktop

I kept adding more and more -I whatever-thing until I got the list down to a size that I could manage and understand.

Wasm schema errors

In this case the solution is:

cargo install -f wasm-bindgen-cli --version 0.2.99
yarn build

I don't know which version should be chosen, but I'm GUESSING:

  • YES "rust Wasm file schema version"
  • NO "this binary schema version"
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.66s
+ wasm-bindgen --out-dir=/home/app/platform/packages/wasm-dpp/wasm --target=web --omit-default-module-path ../../target/wasm32-unknown-unknown/debug/wasm_dpp.wasm
error:

it looks like the Rust project used to create this Wasm file was linked against
version of wasm-bindgen that uses a different bindgen format than this binary:

  rust Wasm file schema version: 0.2.99
     this binary schema version: 0.2.100

Currently the bindgen format is unstable enough that these two schema versions
must exactly match. You can accomplish this by either updating this binary or
the wasm-bindgen dependency in the Rust project.

You should be able to update the wasm-bindgen dependency with:

    cargo update -p wasm-bindgen --precise 0.2.100

don't forget to recompile your Wasm file! Alternatively, you can update the
binary with:

    cargo install -f wasm-bindgen-cli --version 0.2.99

if this warning fails to go away though and you're not sure what to do feel free
to open an issue at https://github.com/rustwasm/wasm-bindgen/issues!

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

No branches or pull requests

1 participant