Brushfam / openbrush-contracts

https://openbrush.io
MIT License
25 stars 10 forks source link

Standardised verifiable builds #110

Open sourabhniyogi opened 1 year ago

sourabhniyogi commented 1 year ago

I tried Standardised verifiable builds on 4 cases (where all 4 cases were generated from ChainIDE WASM Contract templates and compiled in ChainIDE), and flipper compiled but the other 3 did not. Errors are included below:

  1. flipper

NO ERRORS

  1. my_psp22
# docker run -d --name ink-container --mount type=bind,source="./src",target="/contract" paritytech/contracts-verifiable:master build
# docker logs [...]
 [1/*] Building cargo project
error: failed to parse manifest at `/tmp/cargo-contract_RqgRr5/Cargo.toml`

Caused by:
  the target `my_psp22` is a binary and can't have any crate-types set (currentlERROR: command ["/usr/local/rustup/toolchains/1.69-x86_64-unknown-linux-gnu/bin/cargo", "build", "--color=always", "--target=wasm32-unknown-unknown", "-Zbuild-std=core,alloc", "--no-default-features", "--release", "--target-dir=/contract/target/ink", "--features", "ink/ink-debug"] exited with code 101
  1. shiden34
# docker run -d --name ink-container --mount type=bind,source="./src",target="/contract" paritytech/contracts-verifiable:master build
# docker logs [...]
Some errors have detailed explanations: E0405, E0408, E0412, E0425, E0433, E0463, E0531.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `proc-macro2` due to 451 prevERROR: command ["/usr/local/rustup/toolchains/1.69-x86_64-unknown-linux-gnu/bin/cargo", "build", "--color=always", "--target=wasm32-unknown-unknown", "-Zbuild-std=core,alloc", "--no-default-features", "--release", "--target-dir=/contract/target/ink", "--features", "ink/ink-debug"] exited with code 101
  1. factory_contract
# docker run -d --name ink-container --mount type=bind,source="./src",target="/contract" paritytech/contracts-verifiable:master build
# docker logs [...]
ERROR: Error invoking `cargo metadata` for Cargo.toml

Caused by:
    `cargo metadata` exited with an error:     Updating crates.io index
        Updating git repository `https://github.com/727-Ventures/openbrush-contracts`
    error: failed to get `pair_contract` as a dependency of package `factory_contract v0.1.0 (/contract)`

    Caused by:
      failed to load source for dependency `pair_contract`

    Caused by:
      Unable to update /pair

    Caused by:
      failed to read `/pair/Cargo.toml`

    Caused by:
      No such file or directory (os error 2)

We were happy that case 1 generated the same codehash as chainide but any insights to cases 2/3/4 would be appreciated!

@SkymanOne advises that this is not an issue with the (new!) "paritytech/contracts-verifiable" and recommended opening an issue here.

At the end of the day we wish for PSP22/34/Uniswapv2 contract code that can serve as templates that can be verified in paritytech/contracts-verifiable.

coreggon11 commented 1 year ago

Hi @sourabhniyogi , I can see the contracts that failed can not be built with cargo contract v3. Could you try changing #![cfg_attr(not(feature = "std"), no_std)] to #![cfg_attr(not(feature = "std"), no_std, no_main)] and removing the crate-type from Cargo.toml?