Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cargo stylus version to the name of created docker image #88

Closed
rimrakhimov opened this issue Aug 28, 2024 · 2 comments · Fixed by #82 or #91
Closed

Add cargo stylus version to the name of created docker image #88

rimrakhimov opened this issue Aug 28, 2024 · 2 comments · Fixed by #82 or #91

Comments

@rimrakhimov
Copy link

rimrakhimov commented Aug 28, 2024

Currently created docker image name includes only the version of the rust toolchain and does not include the version of the cargo stylus package (CARGO_PKG_VERSION) - https://github.com/OffchainLabs/cargo-stylus/blob/main/check/src/docker.rs#L44-L47

That may result in the following scenario when next versions of the cargo stylus are released:

  1. A user has used cargo stylus 0.4.2 with rust-toolchain 1.80.0, deployed some contracts via that setup and has cargo-stylus-1.80.0 image installed locally.
  2. The user updates cargo stylus to v0.5.0
  3. Deploys a new contract with new v0.5.0 version. The code then just checks if cargo-stylus-1.80.0 image exists locally (https://github.com/OffchainLabs/cargo-stylus/blob/main/check/src/docker.rs#L45) and as it already does, it uses that image that internally has cargo stylus 0.4.2 installed.
  4. When trying to verify the contract, the user believes that v0.5.0 version was used, while in reality it was v0.4.2

Solution

I suggest to add a current cargo stylus version in the docker image name as well - e.g. cargo-stylus-0.4.2-1.80.0

@rimrakhimov
Copy link
Author

Hi, @rauljordan

I don't think #82 closed this issue. The problem was related to the fact that cargo stylus version was not used in the generated docker image name, and it still does not. Actually, with cargo-stylus v0.5.0 being released, you can reproduce that issue in practice:

  1. Start with cargo-stylus v0.4.2 (cargo install cargo-stylus-check --version 0.4.2 --force and cargo install cargo-stylus --version 0.4.2 --force)
  2. Initialize a new cargo stylus project (cargo stylus new)
  3. Deploy a stylus-hello example via reproducible build (cargo stylus deploy --private-key=XXX). That step build and save cargo-stylus-1.79.0 image on your local machine
  4. Uninstall cargo-stylus v0.4.2 and install v0.5.0 instead (cargo uninstall cargo-stylus, cargo uninstall cargo-stylus-check, cargo install cargo-stylus --version 0.5.0 --force)
  5. Deploy the same stylus-hello example (cargo stylus deploy --private-key=XXX). You can notice that no new image has been build and cargo-stylus v0.4.2 was still used

@rauljordan
Copy link
Contributor

hi @rimrakhimov thanks - I was able to reproduce. The issue was in the Rust code that detected the correct image was there. That code was not updated to support the correct version in name + toolchain, and we have fixed in #91 if you wish to try it out by removing cargo-stylus and doing cargo install --path main from source. Then, step (5) will be different and build the new image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants