Skip to content

Conversation

lanterno
Copy link
Contributor

@lanterno lanterno commented Sep 1, 2025

Description

With the merge of the last PR #17, the project is now ready to run with Rust 1.89 (latest stable version as of the time of writing).
In the PR, I update Rust version, and also update all the WASM libraries to the latest versions.

Notice the change in the script file scripts/build-package.sh where this change arises from a very subtle change in the workings of the library wasm-bindgen.
This encourages a rethink on this part of the build script to avoid future bugs.

Next steps

In the following PR, I'll update the docknetwork crypto libraries to the latest versions. In fact, this PR is a prerequisite to updating the libraries as the dependencies conflict otherwise.

PR checklist

  • Run yarn install; yarn build; yarn test to make sure everything runs as before.
  • The commit message(s) follow conventional commits
  • Documentation has been added / updated (for bug fixes / features)
  • Changes follow the contributing document.

Does this PR introduce a breaking change?

  • Yes
  • No

Which merge strategy will you use?

  • Squash
  • Rebase (REVIEW COMMITS)

@lanterno lanterno changed the title build: updates rust version and crates to latest versions build: updates rust version and WASM crates to latest versions Sep 1, 2025
@lanterno lanterno force-pushed the build/pushes-rust-version-and-crates-to-latest-versions branch from 1bff5a7 to 9ece847 Compare September 1, 2025 11:56
@lanterno
Copy link
Contributor Author

lanterno commented Sep 1, 2025

The build failed, and by some investigation, I found the reason to be the github action https://github.com/jetli/wasm-pack-action was using version 'v0.9.1'.
By replacing this with a direct instal of the latest version of wasm-pack, the build now succeeds.

@lanterno
Copy link
Contributor Author

lanterno commented Sep 1, 2025

Now, the tests fail with error

A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
Test Suites: 1 failed, 12 passed, 13 total
Tests:       2 skipped, 145 passed, 147 total
Snapshots:   0 total
Time:        149.43 s

I'm guessing that's because of a memory leak indeed. I don't notice this on my local machine, but I'll try to improve the tests anyway, and see if that makes a difference.

@lanterno lanterno force-pushed the build/pushes-rust-version-and-crates-to-latest-versions branch from 4f0b5ca to fd85963 Compare September 1, 2025 14:20
@lanterno
Copy link
Contributor Author

lanterno commented Sep 1, 2025

Update: Rerunning the tests with no code updates succeeded with no issues.

I'll leave this issue for now, and we can come back to this problem later after the final update of the libraries.

@lanterno lanterno force-pushed the build/pushes-rust-version-and-crates-to-latest-versions branch from fd85963 to b4e6710 Compare September 1, 2025 14:39
wasm-bindgen = "= 0.2.100"
dlmalloc = { version = "0.2.6", features = ["global"], optional = true }
serde_with = { version = "1.10.0", default-features = false, features = ["macros"] }
serde_with = { version = "3.14.0", default-features = false, features = ["macros"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading this caused the serialization to change which is a breaking change so we need adapt in the TS lib (these tests specifically). The old serialized data used in those tests is here.
Is there a feature that you want from the upgraded version of this dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading this .... The old serialized data used in those tests is here.

Oh! It didn't come to mind to look at the crypto-wasm-ts until I finished the updates here. Now, I'm thinking maybe I need to start running the crypto-wasm-ts tests on this library today.

Is there a feature that you want from the upgraded version of this dependency?

Not really! I was just worried that it's lagging behind with 2 major versions. However, since there's no incompatibility problems raised by this so far, I can just postpone until later to avoid having many issues to solve in crypto-wasm-ts at the same time.

serde_json = { version = "1.0"}
serde-wasm-bindgen = "0.6.5"
wasm-bindgen = "= 0.2.86"
wasm-bindgen = "= 0.2.100"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar concern as with the serde_with dependency, i think upgrading it changed some serialisation but I am not that confident of my memory here. (Should have put a note for the reason of pinning it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, this is a bit tricky as this update is needed for newer versions of rust, and also to avoid conflicting dependencies with the latest version of the crypto crates. (I've already tried updating the dock crypto crates to the latest version but this pinned version was a problem.)

I'm thinking about trying to load this library into crypto-wasm-ts and run the tests to make sure they succeed, then we can proceed on this. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about trying to load this library into crypto-wasm-ts and run the tests to make sure they succeed, then we can proceed on this. What do you think?

Yes, for bigger upgrades, i run crypto-wasm-ts with crypto-wasm before publishing crypto-wasm itself. I make crypto-wasm a local dependency of crypto-wasm-ts. For some reason, yarn link sometimes didn't work so I had to manually remove the dependency's directory from node_modules when I updated the dependency (crypto-wasm here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggled with that a bit yesterday, until I found that new versions of yarn introduced the portal keyword, and it works like this (in your package.json file).

"crypto-wasm-new": "portal:../crypto-wasm",

This works without issues for me so far.
The link command was removed in newer versions of yarn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Lovesh, I've worked on the crypto-wasm-ts to make sure the changes here are good (as we said above).

Now, I have this PR with the necessary changes to make everything work.
The necessary changes are in this PR docknetwork/crypto-wasm-ts#43

Note that in one commit docknetwork/crypto-wasm-ts@bed0d12 I had to remove a bunch of tests because we've removed the old proof-system dependency which means this support is gone now.

Does this look okay to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lovesh, can you take a look at this? (Sorry, I know you're busy).

Copy link
Collaborator

@lovesh lovesh Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serialized tests are for backward compatibility. We might be able to remove some old versions but removing all of them wont be acceptable. I suggest upgrading only those packages which are mandatory. So serde-with can be skipped. And we can remove presentation test of old versions except last version but not credential. The idea is that credentials are long lives, presentations are not. Atleast for now.
Similar for wasm-bindgen, if older version works, lets keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lovesh That makes sense.. I want to try and fix this, but because I had to remove the support for the proof-system create, the old version, and only keep the new version, This led to this change in the code of crypto-wasm-ts https://github.com/docknetwork/crypto-wasm-ts/pull/43/files#diff-b86b6f7a55975780458736fa94595903934cc4cdea2947e031207fed5ccaeccfL130-L146

However, you can see that all version below 0.9 depend on the old version. This is why I had to delete all of them.
That said, I didn't know that serde-with might actually be relevant here.
Given what I just said about the old proof-system crate, do you think resetting serde-with to an older version should still fix this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serde-with is used to serialize params, public keys, etc as well so if you keep its (and wasm-bindgen) version same , lot of tests in ts repo will most likely start passing

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