Add Rust specific build info to metadata#680
Conversation
Since we hardcode these into `cargo-contract` we shouldn't need to track these manually
|
I don't think we should add the wasm-opt version. We should have a useable |
Sure, but until that happens this is still needed. We can get rid of that field once that crate is published. |
| #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] | ||
| pub struct BuildInfo { | ||
| /// The stable version of `rustc` used to build the contract. | ||
| pub rustc_version: Version, |
There was a problem hiding this comment.
Can/should we also add the toolchain which contains the architecture? e.g. stable-x86_64-unknown-linux-gnu. I remember there being some discussions about this affecting the wasm bytecode output, can't remember what the conclusions were.
|
|
||
| Ok(optimization_result) | ||
| let cargo_contract_version = | ||
| if let Ok(version) = Version::parse(env!("CARGO_PKG_VERSION")) { |
There was a problem hiding this comment.
AFAIU CARGO_PKG_VERSION is only available at compile time (and also during cargo run). So would need to be captured in a const e.g. const VERSION: &'static str = env!("CARGO_PKG_VERSION");
Since we're using the `wasm-opt` library from crates.io we'll assume that every matching version of `cargo-contract` contains the same version of `wasm-opt`. This doesn't hold if a user installs without the `--locked` flag though, so we may want to add this back in the future to warn users if there are mismatching `wasm-opt` versions.
| /// | ||
| /// Useful for producing deterministic builds. | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub build_info: Option<Map<String, Value>>, |
There was a problem hiding this comment.
Curious why we convert to loosely typed json Map here? Is that for alt. compilers e.g. solang to provide arbitrary data here?
There was a problem hiding this comment.
Yep, other compilers may want to include other info here. It's also useful for us if we decide that we need to add/remove info later on
Will close the metadata part of #525.
This is what the new metadata looks like:
The stuff related to the
verifycommand will be done in a follow-up.Note: I've ended up removing the
wasm-optversion from thebuild_infofor now since there'sno easy way to get it from the new
wasm-optlibrary.I'm going to assume that two installations of
cargo-contractcontain the samewasm-optlibrary (this only holds if both were installed with
--locked). We should add it back in the futurein order to give users a better indication of what went wrong during the
verifyphase.