-
Notifications
You must be signed in to change notification settings - Fork 180
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
Duplicate case in switch (compile error) when building without cgo #5899
Comments
Seems odd that cc @tarakby |
You're right @bartolomej, building the crypto library without cgo disables everything related to BLS signature, and the length that is normally read from the C code is set to zero. I only added and tested the |
Maybe @jribbink knows more about the flow-emulator build for wasm? |
@tarakby I guess I just assumed that flow-go is also built in a way that it doesn't require cgo. Didn't realise it says that in the README.
After quickly looking into the codebase, it seems like this is true. One example is the So it looks like we can't build a WASM emulator that fully matches the non-WASM emulator in feature completeness without cgo enabled. But it doesn't work to enable CGO when building for wasm/js target, since that's just not yet supported by Go natively. Related discussion: https://stackoverflow.com/questions/54946214/cgo-library-build-to-js-wasm-file The above discussion does however mention there seems to be a way to use cgo and also compile C code to wasm (or at least that Qt somehow solved that limitation), but that sounds pretty hacky and complicated, so not sure if it's worth digging into that. So in summary, I believe we could:
For context, I'm trying to build a PoC of the new fully browser-based playground. We also made this grant proposal: onflow/developer-grants#260 |
Thanks for the context!
|
@tarakby Upon discussing this with @bluesign, looking at the code more closely, and reading your response I think I agree. So in summary:
|
@tarakby @turbolent However for building flow-emulator without cgo, this "duplicate case in switch" compiler error still prevent us from having a successful build. But since that is our concern, I'm thinking of just using my forked repo (where I've fixed the issue already) instead of this one, which would come at a slight cost of having to keep that up-to-date. Do you agree this is the way to go? |
The good news is that BLS can't be used as an account key algorithm, only ECDSA can. BLS isn't used by CLI, and can only be used by the flow-emulator if used in a Cadence contract (a niche use-case as you mentioned). I tried out the fix and noticed it's enough to make flow-emulator build and pass tests. I initially thought the emulator requires multiple fixes and the one you pointed is only the first error. I opened this PR in flow-go, feel free to open a PR on flow-emulator to import the new flow-go version. |
Problem Definition
I'm trying to build flow-emulator for JS/WASM target, but I'm running into this error when building without cgo:
Looks like
SigLen
is 0 when building without cgo - I believe it's because C source isn't included/compiled in the build, so I'm guessing it just defaults to 0?flow-go/module/signature/type_encoder.go
Lines 65 to 70 in e4bdb7e
Proposed Solution
Is there a simple fix we can do to take into account this edge case? Maybe using if/else-if statement instead of switch doesn't cause the same compiler error or something like that?
Definition of Done
flow-go compiles successfully with command such as:
The text was updated successfully, but these errors were encountered: