CosmWasm / optimizer

Dockerfile and script to deterministically produce the smallest possible Wasm for your Rust contract
Apache License 2.0
120 stars 59 forks source link

Missing sense of checksums_intermediate.txt #87

Closed SteMak closed 10 months ago

SteMak commented 2 years ago

The checksums_intermediate.txt file is generated in the artifacts folder with the following data:

ARBITRARY_SHA_256_HASH  ./target/wasm32-unknown-unknown/release/CRATE_NAME.wasm

However, the ARBITRARY_SHA_256_HASH is not hash of the file ./target/wasm32-unknown-unknown/release/CRATE_NAME.wasm.

I'm really not sure how should I use it, and it is not mentioned in readme what the file is responsible for. Please, let me know why the file is needed, or maybe another hash should be written there.

webmaster128 commented 2 years ago

You don't need to use it at all. This is a hash of an intermediate result (after compilation, before wasm-opt IIRC). This is indeed not documented, so leaving this open.

SteMak commented 2 years ago

Thanks for your answer! I've discovered, that the file is generated in optimize.sh and is used in optimize_workspace.sh. I'm not good in docker, but in the Dockerfile the files are responsible for different endpoints, so maybe that's why the file is stored there, like between two separate excursions.

But even in such way, I think it is possible to remove the file after all needed actions executed.

maurolacy commented 1 year ago

This file is in there so that we can easily check if the artefacts of the compilation phase are the same across CPU archs. So far, they are not, which means that the Rust compiler is not deterministic does not produce the same output on different CPU archs. For arch-agnostic targets like wasm32-unknown-unknown, that is.

Perhaps it should be better named checksums_compilation.txt.

Feel free to ignore / remove this file from your builds.

webmaster128 commented 10 months ago

Thanks for bringing this up. In the upcoming version 0.15.0 this file is not created anymore. Sorry for the confusion.