Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
b3eafd3
docker image + tokio
SkymanOne Jun 5, 2023
a11bb5b
docker client draft
SkymanOne Jun 5, 2023
ade7003
refactoring execute func
SkymanOne Jun 6, 2023
26328c6
successful docker build
SkymanOne Jun 6, 2023
773a2ff
persist flags in the main execution context
SkymanOne Jun 6, 2023
763cc77
docker readme + respect host flags
SkymanOne Jun 7, 2023
300b725
add build steps
SkymanOne Jun 7, 2023
7dca32b
better image, custom image arg, container reuse
SkymanOne Jun 8, 2023
55b72f1
fix readme example
SkymanOne Jun 8, 2023
f63a53e
Merge branch 'master' into gn/verifiable-build
SkymanOne Jun 8, 2023
9955f25
fix docs
SkymanOne Jun 8, 2023
5fe03fb
update README
SkymanOne Jun 8, 2023
47d63d0
docs fixes
SkymanOne Jun 12, 2023
6d3d7fd
clarification in the docs
SkymanOne Jun 12, 2023
334ed7c
use locked for cargo install
SkymanOne Jun 12, 2023
55ce730
concat install and cleanup commands
SkymanOne Jun 12, 2023
54e0291
use arg instead of env in dockerfile
SkymanOne Jun 13, 2023
e28ddcb
add version labels
SkymanOne Jun 13, 2023
a51ea03
update comments
SkymanOne Jun 13, 2023
80c9252
decompose the function
SkymanOne Jun 13, 2023
fd4773a
correct argument passing in dockerfile
SkymanOne Jun 13, 2023
b2eb769
refactoring
SkymanOne Jun 13, 2023
23bd332
more fixes
SkymanOne Jun 13, 2023
5bb5ca4
Merge branch 'master' into gn/verifiable-build
SkymanOne Jun 13, 2023
c706c83
using remote registry + bell & whistles (progress bars)
SkymanOne Jun 13, 2023
4c69b28
changelog entry
SkymanOne Jun 13, 2023
427f27b
fixes
SkymanOne Jun 13, 2023
000d302
refactoring
SkymanOne Jun 14, 2023
a8db873
explicitly specify versions of apt packages
SkymanOne Jun 15, 2023
8264529
refactoring
SkymanOne Jun 20, 2023
a86dcce
add module docs
SkymanOne Jun 20, 2023
5722084
Merge branch 'master' into gn/verifiable-build
SkymanOne Jun 20, 2023
2c419eb
refactoring
SkymanOne Jun 20, 2023
085a744
doc fix and optionally use git in docker image
SkymanOne Jun 20, 2023
913d2a9
Error handling for builds
SkymanOne Jun 20, 2023
1d84b3c
use single var in docker and refactor docker module
SkymanOne Jun 21, 2023
d237d73
notes on apple silicon
SkymanOne Jun 21, 2023
d0e00dd
remove unused arg in dockerfile
SkymanOne Jun 21, 2023
2f35698
use target path correctly
SkymanOne Jun 21, 2023
3e157f4
handle building with relative paths + permissions
SkymanOne Jun 26, 2023
b78d91e
Merge branch 'master' into gn/verifiable-build
SkymanOne Jun 26, 2023
9800402
more flags in docker image + fixes
SkymanOne Jun 26, 2023
e489c74
Merge branch 'master' into gn/verifiable-build
SkymanOne Jun 26, 2023
2fd00cf
remove unused code
SkymanOne Jun 26, 2023
02aa0af
add git info to docker metadata
SkymanOne Jun 26, 2023
fa95d79
use env to detect running OS
SkymanOne Jun 26, 2023
ea251da
detect host OS
SkymanOne Jun 26, 2023
696a5d1
non-root docker user
SkymanOne Jun 28, 2023
acf89ad
mount contract to home dir in docker
SkymanOne Jun 28, 2023
217ab6a
give permission to target to everyone
SkymanOne Jun 28, 2023
707bfb1
fix typo
SkymanOne Jun 28, 2023
f620dcc
use current uid and gid for docker
SkymanOne Jun 29, 2023
37ae55d
conditional compilation
SkymanOne Jun 29, 2023
dd6a89d
dont cache ci template and use musl in docker
SkymanOne Jun 29, 2023
5ec303b
OS specific code blocks
SkymanOne Jun 29, 2023
7209fa3
print error logs
SkymanOne Jul 3, 2023
85aceb1
Merge branch 'master' into gn/verifiable-build
SkymanOne Jul 3, 2023
6b8a028
remove the message
SkymanOne Jul 3, 2023
00d82b4
calculate digest in separate func
SkymanOne Jul 3, 2023
14d1236
filter our status msgs in error
SkymanOne Jul 3, 2023
b2faaff
update comments
SkymanOne Jul 4, 2023
73b7166
Merge branch 'master' into gn/verifiable-build
SkymanOne Jul 4, 2023
4700472
resolve other merge conflicts
SkymanOne Jul 4, 2023
0c40092
display container name
SkymanOne Jul 10, 2023
14ab832
Merge branch 'master' into gn/verifiable-build
SkymanOne Jul 10, 2023
92a7867
properly trancate error output
SkymanOne Jul 10, 2023
517b4bf
Merge branch 'master' into gn/verifiable-build
SkymanOne Jul 12, 2023
b6b66e9
apply Andrews suggestions
SkymanOne Jul 12, 2023
590b5b8
proper build step logs
SkymanOne Jul 12, 2023
d515504
fix generation of ABI
SkymanOne Jul 12, 2023
44958e3
hash the cmd, not entrypoint for digest
SkymanOne Jul 12, 2023
ad1ddc6
fix args parsing and add docs
SkymanOne Jul 13, 2023
6e02958
clippy fix
SkymanOne Jul 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
333 changes: 117 additions & 216 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Modern releases of gcc and clang, as well as Visual Studio 2019+ should work.
* (MacOS) `brew install openssl`
* `cargo install cargo-dylint dylint-link`.

* Step 4: (**Optional**) Install [Docker Engine](https://docs.docker.com/engine/install)
to be able to produce verifiable builds.

You can always update the `cargo-contract` binary to the latest version by running the Step 2.

### Installation using Docker Image
Expand All @@ -69,6 +72,16 @@ docker run --rm -it -v $(pwd):/sources paritytech/contracts-ci-linux:production
If you want to reproduce other steps of CI process you can use the following
[guide](https://github.com/paritytech/scripts#reproduce-ci-locally).

### Verifiable builds

Some block explorers require the Wasm binary to be compiled in the deterministic environment.
To achieve it, you should build your contract using Docker image we provide:
```bash
cargo contract build --verifiable
```

You can find more detailed documentation how to use the image [here](/build-image/README.md)

## Usage

You can always use `cargo contract help` to print information on available
Expand Down
1 change: 1 addition & 0 deletions build-image/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
63 changes: 63 additions & 0 deletions build-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM docker.io/bitnami/minideb:bullseye-amd64 as slimmed-rust
Comment thread
SkymanOne marked this conversation as resolved.

# metadata
LABEL io.parity.image.vendor="Parity Technologies" \
Comment thread
SkymanOne marked this conversation as resolved.
io.parity.image.title="contracts-verifiable" \
io.parity.image.documentation="https://github.com/paritytech/scripts/blob/master/\
dockerfiles/ink-ci-linux/README.md" \
Comment thread
SkymanOne marked this conversation as resolved.
Outdated
io.parity.image.description="Inherits from docker.io/bitnami/minideb:bullseye. \
rust nightly, clippy, rustfmt, miri, rust-src, rustc-dev, grcov, rust-covfix, \
llvm-tools-preview, cargo-contract, xargo, binaryen, parallel, codecov, ink, solang" \
io.parity.image.documentation="https://github.com/paritytech/cargo-contract/blob/master/\
build-image/README.md"

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
# The 1.69 toolchain is temporarily required to build ink! contracts because of
# https://github.com/paritytech/cargo-contract/issues/1139
RUST_VERSION=1.69

# Minimal Rust dependencies.
RUN set -eux \
&& apt-get update && apt-get -y install wget \
&& url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init" \
&& wget "$url" \
&& chmod +x rustup-init \
&& ./rustup-init -y --no-modify-path --profile minimal --component rust-src rustfmt --default-toolchain $RUST_VERSION \
&& rm rustup-init \
&& chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
&& rustup --version \
&& cargo --version \
&& rustc --version \
&& apt-get remove -y --auto-remove wget \
&& apt-get -y install gcc \
&& rm -rf /var/lib/apt/lists/*

FROM slimmed-rust as cc-builder

# This is important, see https://github.com/rust-lang/docker-rust/issues/85
ENV RUSTFLAGS="-C target-feature=-crt-static"

RUN apt-get -y update && apt-get -y install gcc g++
# Install cargo contract
RUN cargo install cargo-contract
Comment thread
SkymanOne marked this conversation as resolved.
Outdated

# Cleanup after `cargo install`
RUN rm -rf ${CARGO_HOME}/"registry" ${CARGO_HOME}/"git" /root/.cache/sccache

# apt clean up
RUN apt-get remove -y gnupg && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
Comment thread
SkymanOne marked this conversation as resolved.
Outdated


FROM slimmed-rust as ink-dev

COPY --from=cc-builder /usr/local/cargo/bin/cargo-contract /usr/local/bin/cargo-contract

WORKDIR /contract

# default entry point
ENTRYPOINT ["cargo", "contract", "build", "--release"]
Comment thread
SkymanOne marked this conversation as resolved.
Outdated
44 changes: 44 additions & 0 deletions build-image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Verifiable builds using Docker

Docker image based on our base CI image `<base-ci-linux:latest>`.
Comment thread
SkymanOne marked this conversation as resolved.
Outdated

Used for reproducible builds in `cargo contract build --verifiable`

**Rust versions:**

Currently, the 1.69 toolchain is temporarily required to build ink! contracts because of https://github.com/paritytech/cargo-contract/issues/1139

**Rust tools & toolchains:**

We use stable releases from crates.io

- `cargo-contract`
- `wasm32-unknown-unknown`: The toolchain to compile Rust codebases for Wasm.

[Click here](https://hub.docker.com/repository/docker/paritytech/contracts-verifiable) for the registry.

## Usage

The default entry point is `ENTRYPOINT [ "cargo", "contract", "build", "--release" ]`
and work directory is set to `/contract`. You need to mount the folder with the contract to the container.

```bash
docker run -d \
--name ink-container \
--mount type=bind,source="$(pwd)",target="/contract" \
paritytech/contracts-verified
Comment thread
SkymanOne marked this conversation as resolved.
```

If you have multi-contract project:
Comment thread
SkymanOne marked this conversation as resolved.
Outdated
```
my-app/
├─ ink-project-a/
│ ├─ Cargo.toml
│ ├─ lib.rs
├─ ink-project-b/
│ ├─ Cargo.toml
│ ├─ lib.rs
├─ rust-toolchain
```
Make sure you mount `my-app` directory and then call
Comment thread
SkymanOne marked this conversation as resolved.
Outdated
`cargo contract build --verifiable --release --manifest-path ink-project-a/Cargo.toml`
3 changes: 3 additions & 0 deletions crates/build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ wasm-opt = "0.112.0"
which = "4.4.0"
zip = { version = "0.6.6", default-features = false }
strum = { version = "0.24", features = ["derive"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1"
bollard = "0.14"

contract-metadata = { version = "3.0.1", path = "../metadata" }

Expand Down
5 changes: 3 additions & 2 deletions crates/build/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# contract-build

A crate for building [`ink!`](https://github.com/paritytech/ink) smart contracts. Used by
A crate for building [`ink!`](https://github.com/paritytech/ink) smart contracts. Used by
[`cargo-contract`](https://github.com/paritytech/cargo-contract).

## Usage
Expand Down Expand Up @@ -36,7 +36,8 @@ let args = contract_build::ExecuteArgs {
skip_wasm_validation: false,
target: Target::Wasm,
max_memory_pages: 16,
image: None,
};

contract_build::execute(args);
```
```
12 changes: 10 additions & 2 deletions crates/build/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl TryFrom<&VerbosityFlags> for Verbosity {
}

/// Denotes if output should be printed to stdout.
#[derive(Clone, Copy, Default, serde::Serialize, Eq, PartialEq)]
#[derive(Clone, Copy, Default, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
pub enum Verbosity {
/// Use default output
#[default]
Expand Down Expand Up @@ -89,7 +89,15 @@ impl Network {

/// Describes which artifacts to generate
#[derive(
Copy, Clone, Default, Eq, PartialEq, Debug, clap::ValueEnum, serde::Serialize,
Copy,
Clone,
Default,
Eq,
PartialEq,
Debug,
clap::ValueEnum,
serde::Serialize,
serde::Deserialize,
)]
#[clap(name = "build-artifacts")]
pub enum BuildArtifacts {
Expand Down
Loading