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

signer/core can't compile to wasm due to unix constrains #23972

Closed
goldbock opened this issue Nov 25, 2021 · 3 comments · Fixed by #24029
Closed

signer/core can't compile to wasm due to unix constrains #23972

goldbock opened this issue Nov 25, 2021 · 3 comments · Fixed by #24029
Assignees
Labels

Comments

@goldbock
Copy link

goldbock commented Nov 25, 2021

System information

go-ethereum tip

Expected behaviour

compile to wasm

Actual behaviour

signer/core package does not compile to wasm

Steps to reproduce the behaviour

import "github.com/ethereum/go-ethereum/signer/core"

Use the signer/core to generate an EIP712Domain signature;

Backtrace

      imports github.com/ethereum/go-ethereum/signer/core
        imports github.com/ethereum/go-ethereum/consensus/clique
        imports github.com/ethereum/go-ethereum/consensus
        imports github.com/ethereum/go-ethereum/core/state
        imports github.com/VictoriaMetrics/fastcache
        imports golang.org/x/sys/unix: build constraints exclude all Go files in /Users/x/go/pkg/mod/golang.org/x/sys@v0.0.0-20210910150752-751e447fb3d0/unix

I've used go-ethereum successfully in wasm environment for a while until I had to use EIP712Domain signature and import types from "signer/core". I've fixed the build tags on fast cache in VictoriaMetrics/fastcache#62 but there seem to be other transitive dependencies such leveldb and edsrzf/mmap-go that require file locking.

I believe the TypedData structs should perhaps be exported in a separate package so that the client can generate EIP712Domain signatures without importing (transitively) leveldb and other packages that require file synchronisation.

A more broad scope would be to make the whole go-ethereum sdk wasm compatible ( #16192 ) but that's a different, bigger issue.

@goldbock goldbock changed the title can't compile to wasm due to unix constrains signer/core can't compile to wasm due to unix constrains Nov 25, 2021
@holiman
Copy link
Contributor

holiman commented Nov 25, 2021

Yes, I guess we can move the TypedData to it's own package. Want to make a PR?
EDIT: I can make the move myself, probably simpler, because we'll probably have a lot of nitpicks about naming and what to put in there etc.

@holiman holiman self-assigned this Nov 25, 2021
@goldbock
Copy link
Author

goldbock commented Nov 25, 2021

@holiman I think it would be great if you do it... I will probably mess the package organisation.

As a quick workaround I actually patched (in a brutal/poor way) several packages[0] that throw errors on wasm compilation to make sure that I won't hit unix constraints errors if I ever need to use other go-ethereum packages that have these dependencies.

[0] go-ethereum/accounts/scwallet (disabled support in js)
goleveldb
prometheus-junkyard/tsdb
edsrzf/mmap-go
VictoriaMetrics/fastcache ( easy fix)

@fjl
Copy link
Contributor

fjl commented Nov 28, 2021

Seems to me like package signer/core/apitypes is the ideal location for TypedData. We created this package specifically for types which are used by the RPC API, and it was created because of a similar dependency issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants