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

make gosdk compilable to wasm (go-ethereum not compatible with wasm) #128

Closed
mallochine opened this issue Jun 30, 2021 · 5 comments
Closed
Assignees

Comments

@mallochine
Copy link
Contributor

@moldis please fix this since go-ethereum package is your responsibility.

You can reproduce the compile error by doing this:

  1. git checkout jssdk branch
  2. cd $TOP/_sdkver
  3. GOOS=js GOARCH=wasm go build -o proxy.wasm proxy.go ethwallet.go
  4. produces this error message:
../../../go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.3/metrics/cpu_enabled.go:40:79: undefined: "github.com/shirou/gopsutil/cpu".ClocksPerSec
../../../go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.3/metrics/cpu_enabled.go:41:47: undefined: "github.com/shirou/gopsutil/cpu".ClocksPerSec
../../../go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.3/metrics/cpu_syscall.go:30:12: undefined: syscall.Getrusage
../../../go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.3/metrics/cpu_syscall.go:30:30: undefined: syscall.RUSAGE_SELF

The temporary workaround that I'm using (in order to build the wasm taht Hau can use) is to edit those go-ethereum files locally and fix the golang errors by nuking the CPU stat collection.

In order to fix this, Artem you need to do either one of the following two:

  • submit patch to go-ethereum to fix their build for wasm by nuking the CPU stats
  • fork go-ethereum, host a public version on 0chain with the fixed patch that wasm can build.

@moldis also this is way outside the scope of my responsibilities, so I'm assigning to you

@Rizary
Copy link
Contributor

Rizary commented Jul 6, 2021

there is an active PR ethereum/go-ethereum#23046 that solves the above error. I have tried it in my local machine.

@mallochine
Copy link
Contributor Author

hey nice find

@Rizary
Copy link
Contributor

Rizary commented Jul 16, 2021

@mallochine sorry for taking this too long. I ask the go-ethereum devs but it seems they still not review the above PR. I tried to update our mod using go get github.com/certifaction/go-ethereum@BP-3079-clien-compile-wasm, and get this error when I try to update using go mod tidy:

go: github.com/certifaction/go-ethereum@v1.10.3-wasm: parsing go.mod:
	module declares its path as: github.com/ethereum/go-ethereum
	        but was required as: github.com/certifaction/go-ethereum

turns out, it happened because it is still use github.com/ethereum/go-ethereum as module name in here: https://github.com/certifaction/go-ethereum/blob/BP-3079-clien-compile-wasm/go.mod#L1

Do you have any other suggestion?

@cnlangzi
Copy link
Contributor

use go replace on go.mod , and git clone it on ci job first

@Rizary
Copy link
Contributor

Rizary commented Jul 30, 2021

closed as #141

@Rizary Rizary closed this as completed Jul 30, 2021
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

4 participants