Skip to content

[SPO-53] Support specifying profiles - #209

Merged
rasmus-kirk merged 12 commits into
mainfrom
support-profiles
Dec 2, 2025
Merged

[SPO-53] Support specifying profiles#209
rasmus-kirk merged 12 commits into
mainfrom
support-profiles

Conversation

@rasmus-kirk

@rasmus-kirk rasmus-kirk commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

Purpose

I split up #208 to make the review easier. This only handles specifying profiles with the --profile parameter, reproducible builds in workspaces will not work. This PR also doesn't support passing in the --profile flag to reproducible builds. Given that the coming PR will be about reproducible builds, I chose to leave this PR lighter.

Changes

  • Refactored invocations of cargo build to use a single wrapper method to more easily manage the arguments we pass.
  • Add a --release flag to specify the release profile.
  • build_contract now takes the BuildOptions struct for simplicity. This was more ergonomic than adding yet another parameter for the release profile.

Testing

I tested this feature by adding:

[profile.test-profile]
inherits = "release"
opt-level = "s"

To the reproducible smart contract and running:

> rm -r target; cargo-concordium test --profile test-profile 
rm: cannot remove 'target': No such file or directory
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.11s
     Running `/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/cargo-concordium/target/debug/cargo-concordium concordium test --profile test-profile`
   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling base64 v0.21.7
   Compiling fnv v1.0.7
   Compiling hashbrown v0.11.2
   Compiling quote v1.0.40
   Compiling syn v2.0.101
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/reproducible/example-contract)
    Finished `test-profile` profile [optimized] target(s) in 3.79s

Running unit tests ...
Unit test result: ok
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/reproducible/example-contract)
    Finished `test-profile` profile [optimized] target(s) in 1.90s
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/reproducible/example-contract)
    Finished `test-profile` profile [optimized] target(s) in 1.92s


This is not a verifiable build. Consider using the `--verifiable` option before deploying the module.

A verifiable build packages sources and makes it possible to verify that the sources match the deployed module.

Running integration tests ...
Running cargo test
   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling fnv v1.0.7
   Compiling hashbrown v0.11.2
   Compiling base64 v0.21.7
   Compiling quote v1.0.40
   Compiling syn v2.0.101
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/reproducible/example-contract)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 3.79s
     Running unittests src/lib.rs (target/debug/deps/test_contract-28cc41f13cd6ac84)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests test_contract

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

All tests passed

And:

> rm -r target; cargo-concordium build --profile test-profile
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.16s
     Running `/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/cargo-concordium/target/debug/cargo-concordium concordium build --profile test-profile`
   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling hashbrown v0.11.2
   Compiling base64 v0.21.7
   Compiling fnv v1.0.7
   Compiling quote v1.0.40
   Compiling syn v2.0.101
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/reproducible/example-contract)
    Finished `test-profile` profile [optimized] target(s) in 3.85s
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/reproducible/example-contract)
    Finished `test-profile` profile [optimized] target(s) in 1.91s

   Module schema includes:

   Total size of the module schema is 7 B
   Embedding schema into module.

    Finished smart contract module 20.004 kB


This is not a verifiable build. Consider using the `--verifiable` option before deploying the module.

A verifiable build packages sources and makes it possible to verify that the sources match the deployed module.

And for good measure:

> cargo-concordium build --verifiable "localhost/my-verifiable-rust:latest"
   Compiling cargo-concordium v4.2.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/cargo-concordium)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.76s
     Running `/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/cargo-concordium/target/debug/cargo-concordium concordium build --verifiable 'localhost/my-verifiable-rust:latest'`
   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling hashbrown v0.11.2
   Compiling fnv v1.0.7
   Compiling base64 v0.21.7
   Compiling quote v1.0.40
   Compiling syn v2.0.101
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/home/user/desktop/concordium/aaaaaaa/concordium-smart-contract-tools/reproducible/example-contract)
    Finished `release` profile [optimized] target(s) in 3.85s
    Updating crates.io index
 Downloading crates ...
  Downloaded quote v1.0.40
  Downloaded proc-macro2 v1.0.95
  Downloaded unicode-ident v1.0.18
  Downloaded fnv v1.0.7
  Downloaded concordium-contracts-common-derive v4.1.0
  Downloaded hashbrown v0.11.2
  Downloaded concordium-contracts-common v9.2.0
  Downloaded base64 v0.21.7
  Downloaded concordium-std v10.1.0
  Downloaded syn v2.0.101
   Compiling proc-macro2 v1.0.95
   Compiling unicode-ident v1.0.18
   Compiling fnv v1.0.7
   Compiling base64 v0.21.7
   Compiling hashbrown v0.11.2
   Compiling quote v1.0.40
   Compiling syn v2.0.101
   Compiling concordium-contracts-common-derive v4.1.0
   Compiling concordium-contracts-common v9.2.0
   Compiling concordium-std v10.1.0
   Compiling test-contract v0.1.0 (/b)
    Finished `release` profile [optimized] target(s) in 5.91s
warning: no passes specified, not doing any work

   Module schema includes:

   Total size of the module schema is 7 B
   Embedding schema into module.

  Embedded build information information:

    - Build image used: localhost/my-verifiable-rust:latest
    - Build command used: cargo build --target wasm32-unknown-unknown --profile release --package test-contract --target-dir /b/t --locked
    - Hash of the archive: 9f50605d6aae548dd4d09386dcf433e6b9b28ce7b8c4f27878978e6ef631fb9a
    - No link to source code embedded.

    - Archived source files:
        - Cargo.lock
        - Cargo.toml
        - src
        - src/lib.rs
    Finished smart contract module 20.216 kB

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

@rasmus-kirk
rasmus-kirk marked this pull request as ready for review November 24, 2025 15:10

@rasmus-kirk rasmus-kirk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts

Comment thread cargo-concordium/src/context.rs
Comment thread cargo-concordium/src/build.rs Outdated
Comment thread cargo-concordium/src/build.rs
Comment thread cargo-concordium/src/build.rs
Comment thread cargo-concordium/src/build.rs
Comment thread cargo-concordium/src/build.rs
Comment thread cargo-concordium/src/build.rs Outdated
Comment thread cargo-concordium/src/build.rs
@rasmus-kirk rasmus-kirk changed the title Support specifying profiles Support specifying profiles SPO-53 Nov 26, 2025
@rasmus-kirk rasmus-kirk changed the title Support specifying profiles SPO-53 [SPO-53] Support specifying profiles Nov 26, 2025
Comment thread cargo-concordium/src/build.rs Outdated
@rasmus-kirk
rasmus-kirk force-pushed the support-profiles branch 2 times, most recently from cb7a412 to b4127b5 Compare November 27, 2025 13:43
Comment thread cargo-concordium/src/build.rs
@rasmus-kirk

Copy link
Copy Markdown
Contributor Author

Also reverted the changes to get_cargo_metadata for less review burden, I can include that seperately in another PR, so that it's the only change.

Comment thread cargo-concordium/src/build.rs Outdated
Comment thread reproducible/example-contract/Cargo.lock
Comment thread cargo-concordium/src/build.rs
rasmus-kirk and others added 3 commits November 29, 2025 12:20
@rasmus-kirk rasmus-kirk mentioned this pull request Dec 2, 2025
5 tasks
@rasmus-kirk

Copy link
Copy Markdown
Contributor Author

I'm merging this if it's good to you @allanbrondum

@rasmus-kirk
rasmus-kirk merged commit 51a39d3 into main Dec 2, 2025
4 checks passed
@rasmus-kirk
rasmus-kirk deleted the support-profiles branch December 2, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants