-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Replace wasm as-sha256 with pure js noble-hashes #313
Comments
+1 to this! I was going to open a similar issue just now. At MetaMask we have also had to deal with this dependency being introduced into our dependency tree (via
We are currently forced to exclude |
I see your concerns and would love to find a setup to benefits both web and nodejs consumers. For Lodestar's beacon node the speed of 64B hashes is crucial for performance since it's one of the most frequent ops we do. @FrederikBolding would there be some approach like platform aware entrypoints that would fix your build issue? Say a-la https://www.npmjs.com/package/cross-fetch |
@dapplion Yeah. Separate entry points for the browser, React Native and Node.js (e.g. via package.json fields) may alleviate some of the pain points for us. However, the ideal would probably be the possibility to opt-in/out of using WASM at all. Not sure if there is a good pattern for doing that other than publishing two packages 😅 |
Why not allow passing sha implementation as a function? Default can be either no hashing at all or noble-hashes because of compatibility. |
That should work too right CC @wemeetagain |
That sounds like a good idea to me! |
That's what we are doing in our trie library (after a similar discussion): https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/trie/src/types.ts#L51 |
Looks like the proposed fix has been released for this, but it uses the I have yet to try bumping in the MetaMask extension, but there is a chance that our build pipeline doesn't support |
I agree, using exports field for this particular case does not bring any benefits. Removing
will need to be removed; files will need to be moved top-level (lib/hasher/index.js => hasher/index.js) OR export paths will need to be renamed (hashes/noble => lib/hasher/noble.js) |
This is not exactly an exotic or new feature, it has been a feature since node v12.7.0. And it's the recommended approach according to the docs. Unfortunately, as we've seen, there are problems. Collecting links here for posterity.
I was hoping that this would be an opportunity to file a bug, make fix in upstream tooling, or to fix some tooling configuration. However it seems that this is a known issue that does not have a positive outlook for being resolved in the near term. I think we can mitigate this by using the same strategy as is used in the |
@wemeetagain It's not as elegant as exports, but this works for Browserify and Webpack: #318 I have verified that this fixes any problems in the MetaMask extension build process when importing |
🙏 Thanks a lot for the feedback, great timing since I am just preparing release notes for releases today including this fix! 🙂 |
@holgerd77 Sorry, just to clarify. We'll need to fix the exports issue before the MetaMask problems are entirely fixed. But haven't gotten a response on that PR yet. |
Ok, I'll pause our release process (nothing urgent to be released), maybe there is a chance that this can get settled and still included within our release round. |
@paulmillr @FrederikBolding |
(it's slightly slower for 32B inputs, but executing 1 million hashes of 32b items at once is not a common case)
The text was updated successfully, but these errors were encountered: