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

Sometimes creates empty wasm binaries #3

Closed
de-husk opened this issue Jul 20, 2022 · 6 comments · Fixed by #5
Closed

Sometimes creates empty wasm binaries #3

de-husk opened this issue Jul 20, 2022 · 6 comments · Fixed by #5
Assignees

Comments

@de-husk
Copy link
Contributor

de-husk commented Jul 20, 2022

Awesome project!

I ran into an issue trying to use it with this workspace: https://github.com/DA0-DA0/dao-contracts

It produced nearly empty optimized wasm binaries for cw20_stake and cw_core contracts.

When I tried to use them, I got this error:

Error calling the VM: Error during static Wasm validation: Wasm contract doesn't have required export: "instantiate". Exports required by VM: ["allocate", "deallocate", "instantiate"].: create wasm contract failed: invalid request

Im wondering if optimizoor is compiling them with the library feature enabled?

@mandrean mandrean self-assigned this Jul 21, 2022
@mandrean
Copy link
Owner

Hey @de-husk, thanks for reporting! Appreciate it. Will have a look.

@mandrean
Copy link
Owner

mandrean commented Jul 21, 2022

Okay, found the issue. Basically this can happen in monorepos where each member of the workspace has its own lockfile, like the DA0-DA0 contracts

Current implementation assumes the monorepo shares one lockfile. Shouldn't be too difficult to support both cases

@mandrean
Copy link
Owner

mandrean commented Jul 22, 2022

I digged quite a bit deeper into this, and the lockfile hypothesis was just a coincidence. It's actually a bug(/feature) in cargo itself:
rust-lang/cargo#3620
rust-lang/cargo#8157 (comment)
rust-lang/cargo#4463
rust-lang/cargo#4866
rust-lang/cargo#10266 (comment)

ehuss commented on Jul 6, 2020
Thanks for the report! This is a known issue /.../
The --workspace flag causes all features of all workspace members to be unified.

If you have a workspace where a member (e.g. DA0-DA0/cw_core) is both a release binary and a library/dependency to some other binary, then cargo will "simplify" the dependency graph by only compiling that member (cw_core in this case) once - with the feature flag set - causing that to spill over into the release binary as well!

image

Looking into if there is a way to influence/work around this in an efficient way

@mandrean
Copy link
Owner

Okay @de-husk, I have a workaround! Check #5

@de-husk
Copy link
Contributor Author

de-husk commented Aug 17, 2022

This is looking good btw. Thanks for the quick fix!

@mandrean
Copy link
Owner

Thanks for reporting the bug! Much appreciated.

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 a pull request may close this issue.

2 participants