-
Notifications
You must be signed in to change notification settings - Fork 34
Reduce contract binary size
jjy edited this page Jun 30, 2020
·
1 revision
This suggestion is from the article Formatting is Unreasonably Expensive for Embedded Rust.
We should make sure our code and dependencies crates do not contain format!
and formatting version panic!
macros, since these macros generated code increases the size of our binary craziness.
Note, the non-formatting version
panic!
is OK to use. Thedebug!
macro is also OK to use sincedebug!
generates no code in the release mode.
Follow the steps to check your contract:
- make sure to use
0.4.1
or a later versionckb-std
, which contains no formatting macro. - check your other dependencies to make sure there're no formatting macro be used.
- check contract code.
- try to use
opt-level = 's'
options inCargo.toml
, which generates a smaller binary for demo contracts.