Skip to content

Fix how cosmwasm-plus compiles #21

@ethanfrey

Description

@ethanfrey

We made a great simplification by just running the compile step one time on the top level folder even with multple workspaces: https://github.com/CosmWasm/rust-optimizer/blob/v0.10.1/optimize.sh#L25

However, when we run this on cosmwasm-plus we get cw1_whitelist with a size of 13kb. That is due to the 'library' feature being enabled when imported by subkeys, so no exports and almost everything gets optimized out.

Features are the union of all crates referencing it. In order to allow these crates to be imported as libraries and also compiled alone, we need to run the cargo build script once per contract. We also decided we cannot pass argument on the command-line, so I propose something like the following:

  • cd $1
  • check Cargo.toml exists
  • if there is a [package]name entry then compile there
  • if there is a [package]members entry, then go into each directory listed there and run the build script in each one

This should work the same for cosmwasm and cosmwasm-examples and cosmwasm-template. The only change would be cosmwasm-plus, where we get the previous behavior (listing .contracts/*) without passing that explicitly. We may need a tool to parse the toml file beyond grep. https://github.com/freshautomations/stoml is interesting but not sure if we can apt install it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions