diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3614efb16..40ad19d50 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,8 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+- Standardised verifiable builds - [#1148](https://github.com/paritytech/cargo-contract/pull/1148)
+
### Changed
-- Dry-run result output improvements [1123](https://github.com/paritytech/cargo-contract/pull/1123)
+- Dry-run result output improvements - [1123](https://github.com/paritytech/cargo-contract/pull/1123)
- Display build progress with --output-json, print to stderr [1211](https://github.com/paritytech/cargo-contract/pull/1211)
### Fixed
@@ -17,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [3.0.1]
### Fixed
-- `[contract-build]` flush the remaining buffered bytes [1118](https://github.com/paritytech/cargo-contract/pull/1118)
+- `[contract-build]` flush the remaining buffered bytes - [1118](https://github.com/paritytech/cargo-contract/pull/1118)
## [3.0.0]
@@ -28,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Contracts are build as `bin` crate now (we used `cdylib` before) - [#1076](https://github.com/paritytech/cargo-contract/pull/1076)
- BREAKING CHANGE: Make sure that your contract is `no_main` by having this on top of your contract:
- `#![cfg_attr(not(feature = "std"), no_std, no_main)]`
- - This will be detected and suggested for `error[E0601]` [#1113](https://github.com/paritytech/cargo-contract/pull/1113)
+ - This will be detected and suggested for `error[E0601]` - [#1113](https://github.com/paritytech/cargo-contract/pull/1113)
- Update contracts node metadata (#1105)
- Compatible with `substrate-contracts-node 0.25.0-a2b09462c7c`
diff --git a/Cargo.lock b/Cargo.lock
index 1ec8583e5..a61d1a9d6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -198,77 +198,6 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9"
-[[package]]
-name = "async-attributes"
-version = "1.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5"
-dependencies = [
- "quote",
- "syn 1.0.109",
-]
-
-[[package]]
-name = "async-channel"
-version = "1.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833"
-dependencies = [
- "concurrent-queue",
- "event-listener",
- "futures-core",
-]
-
-[[package]]
-name = "async-executor"
-version = "1.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb"
-dependencies = [
- "async-lock",
- "async-task",
- "concurrent-queue",
- "fastrand",
- "futures-lite",
- "slab",
-]
-
-[[package]]
-name = "async-global-executor"
-version = "2.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776"
-dependencies = [
- "async-channel",
- "async-executor",
- "async-io",
- "async-lock",
- "blocking",
- "futures-lite",
- "once_cell",
- "tokio",
-]
-
-[[package]]
-name = "async-io"
-version = "1.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af"
-dependencies = [
- "async-lock",
- "autocfg",
- "cfg-if",
- "concurrent-queue",
- "futures-lite",
- "log",
- "parking",
- "polling",
- "rustix 0.37.22",
- "slab",
- "socket2",
- "waker-fn",
-]
-
[[package]]
name = "async-lock"
version = "2.7.0"
@@ -278,56 +207,17 @@ dependencies = [
"event-listener",
]
-[[package]]
-name = "async-std"
-version = "1.12.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d"
-dependencies = [
- "async-attributes",
- "async-channel",
- "async-global-executor",
- "async-io",
- "async-lock",
- "crossbeam-utils",
- "futures-channel",
- "futures-core",
- "futures-io",
- "futures-lite",
- "gloo-timers",
- "kv-log-macro",
- "log",
- "memchr",
- "once_cell",
- "pin-project-lite",
- "pin-utils",
- "slab",
- "wasm-bindgen-futures",
-]
-
-[[package]]
-name = "async-task"
-version = "4.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ecc7ab41815b3c653ccd2978ec3255c81349336702dfdf62ee6f7069b12a3aae"
-
[[package]]
name = "async-trait"
-version = "0.1.69"
+version = "0.1.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b2d0f03b3640e3a630367e40c468cb7f309529c708ed1d88597047b0e7c6ef7"
+checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
-[[package]]
-name = "atomic-waker"
-version = "1.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3"
-
[[package]]
name = "autocfg"
version = "1.1.0"
@@ -469,18 +359,42 @@ dependencies = [
]
[[package]]
-name = "blocking"
-version = "1.3.1"
+name = "bollard"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77231a1c8f801696fc0123ec6150ce92cffb8e164a02afb9c8ddee0e9b65ad65"
+checksum = "af254ed2da4936ef73309e9597180558821cb16ae9bba4cb24ce6b612d8d80ed"
dependencies = [
- "async-channel",
- "async-lock",
- "async-task",
- "atomic-waker",
- "fastrand",
- "futures-lite",
+ "base64 0.21.2",
+ "bollard-stubs",
+ "bytes",
+ "futures-core",
+ "futures-util",
+ "hex",
+ "http",
+ "hyper",
+ "hyperlocal",
"log",
+ "pin-project-lite",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "serde_repr",
+ "serde_urlencoded",
+ "thiserror",
+ "tokio",
+ "tokio-util",
+ "url",
+ "winapi",
+]
+
+[[package]]
+name = "bollard-stubs"
+version = "1.42.0-rc.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "602bda35f33aeb571cef387dcd4042c643a8bf689d8aaac2cc47ea24cb7bc7e0"
+dependencies = [
+ "serde",
+ "serde_with",
]
[[package]]
@@ -557,13 +471,12 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3"
[[package]]
name = "bstr"
-version = "1.5.0"
+version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
+checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05"
dependencies = [
"memchr",
- "once_cell",
- "regex-automata 0.1.10",
+ "regex-automata 0.3.2",
"serde",
]
@@ -634,7 +547,6 @@ version = "3.0.1"
dependencies = [
"anyhow",
"assert_cmd",
- "async-std",
"clap",
"colored",
"contract-build",
@@ -648,6 +560,7 @@ dependencies = [
"substrate-build-script-utils",
"subxt",
"tempfile",
+ "tokio",
"tracing",
"tracing-subscriber 0.3.17",
"url",
@@ -701,6 +614,7 @@ dependencies = [
"android-tzdata",
"iana-time-zone",
"num-traits",
+ "serde",
"winapi",
]
@@ -736,7 +650,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -782,12 +696,16 @@ dependencies = [
]
[[package]]
-name = "concurrent-queue"
-version = "2.2.0"
+name = "console"
+version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c"
+checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8"
dependencies = [
- "crossbeam-utils",
+ "encode_unicode",
+ "lazy_static",
+ "libc",
+ "unicode-width",
+ "windows-sys 0.45.0",
]
[[package]]
@@ -802,6 +720,7 @@ version = "3.0.1"
dependencies = [
"anyhow",
"blake2",
+ "bollard",
"cargo_metadata",
"clap",
"colored",
@@ -810,9 +729,11 @@ dependencies = [
"heck",
"hex",
"impl-serde",
+ "indicatif",
"parity-scale-codec",
"parity-wasm",
"pretty_assertions",
+ "regex",
"rustc_version",
"semver",
"serde",
@@ -820,9 +741,12 @@ dependencies = [
"strum 0.25.0",
"tempfile",
"term_size",
+ "tokio",
+ "tokio-stream",
"toml 0.7.6",
"tracing",
"url",
+ "users",
"wabt",
"walkdir",
"wasm-opt",
@@ -835,7 +759,6 @@ name = "contract-extrinsics"
version = "3.0.1"
dependencies = [
"anyhow",
- "async-std",
"clap",
"colored",
"contract-build",
@@ -853,6 +776,7 @@ dependencies = [
"sp-runtime",
"sp-weights",
"subxt",
+ "tokio",
"tracing",
"url",
]
@@ -927,9 +851,9 @@ dependencies = [
[[package]]
name = "cpufeatures"
-version = "0.2.8"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c"
+checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1"
dependencies = [
"libc",
]
@@ -1031,9 +955,9 @@ dependencies = [
[[package]]
name = "cxx"
-version = "1.0.97"
+version = "1.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e88abab2f5abbe4c56e8f1fb431b784d710b709888f35755a160e62e33fe38e8"
+checksum = "e928d50d5858b744d1ea920b790641129c347a770d1530c3a85b77705a5ee031"
dependencies = [
"cc",
"cxxbridge-flags",
@@ -1043,9 +967,9 @@ dependencies = [
[[package]]
name = "cxx-build"
-version = "1.0.97"
+version = "1.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c0c11acd0e63bae27dcd2afced407063312771212b7a823b4fd72d633be30fb"
+checksum = "8332ba63f8a8040ca479de693150129067304a3496674477fff6d0c372cc34ae"
dependencies = [
"cc",
"codespan-reporting",
@@ -1053,24 +977,24 @@ dependencies = [
"proc-macro2",
"quote",
"scratch",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
name = "cxxbridge-flags"
-version = "1.0.97"
+version = "1.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d3816ed957c008ccd4728485511e3d9aaf7db419aa321e3d2c5a2f3411e36c8"
+checksum = "5966a5a87b6e9bb342f5fab7170a93c77096efe199872afffc4b477cfeb86957"
[[package]]
name = "cxxbridge-macro"
-version = "1.0.97"
+version = "1.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a26acccf6f445af85ea056362561a24ef56cdc15fcc685f03aec50b9c702cb6d"
+checksum = "81b2dab6991c7ab1572fea8cb049db819b1aeea1e2dac74c0869f244d9f21a7c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -1118,7 +1042,7 @@ dependencies = [
"proc-macro2",
"quote",
"strsim",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -1140,7 +1064,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a"
dependencies = [
"darling_core 0.20.1",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -1292,6 +1216,12 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
+[[package]]
+name = "encode_unicode"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
+
[[package]]
name = "env_logger"
version = "0.10.0"
@@ -1477,21 +1407,6 @@ version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964"
-[[package]]
-name = "futures-lite"
-version = "1.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce"
-dependencies = [
- "fastrand",
- "futures-core",
- "futures-io",
- "memchr",
- "parking",
- "pin-project-lite",
- "waker-fn",
-]
-
[[package]]
name = "futures-macro"
version = "0.3.28"
@@ -1500,7 +1415,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -1599,18 +1514,6 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
-[[package]]
-name = "gloo-timers"
-version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c"
-dependencies = [
- "futures-channel",
- "futures-core",
- "js-sys",
- "wasm-bindgen",
-]
-
[[package]]
name = "h2"
version = "0.3.20"
@@ -1677,9 +1580,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
+checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
[[package]]
name = "hex"
@@ -1807,6 +1710,19 @@ dependencies = [
"webpki-roots",
]
+[[package]]
+name = "hyperlocal"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fafdf7b2b2de7c9784f76e02c0935e65a8117ec3b768644379983ab333ac98c"
+dependencies = [
+ "futures-util",
+ "hex",
+ "hyper",
+ "pin-project",
+ "tokio",
+]
+
[[package]]
name = "iana-time-zone"
version = "0.1.57"
@@ -1902,6 +1818,19 @@ dependencies = [
"hashbrown 0.14.0",
]
+[[package]]
+name = "indicatif"
+version = "0.17.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057"
+dependencies = [
+ "console",
+ "instant",
+ "number_prefix",
+ "portable-atomic",
+ "unicode-width",
+]
+
[[package]]
name = "ink"
version = "4.2.1"
@@ -1948,7 +1877,7 @@ dependencies = [
"quote",
"serde",
"serde_json",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -2005,7 +1934,7 @@ dependencies = [
"itertools 0.10.5",
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -2020,7 +1949,7 @@ dependencies = [
"parity-scale-codec",
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
"synstructure",
]
@@ -2124,12 +2053,12 @@ dependencies = [
[[package]]
name = "is-terminal"
-version = "0.4.8"
+version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb"
+checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi",
- "rustix 0.38.2",
+ "rustix 0.38.3",
"windows-sys 0.48.0",
]
@@ -2357,15 +2286,6 @@ dependencies = [
"cpufeatures",
]
-[[package]]
-name = "kv-log-macro"
-version = "1.0.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f"
-dependencies = [
- "log",
-]
-
[[package]]
name = "lazy_static"
version = "1.4.0"
@@ -2468,9 +2388,6 @@ name = "log"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
-dependencies = [
- "value-bag",
-]
[[package]]
name = "mach"
@@ -2511,7 +2428,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e"
dependencies = [
- "rustix 0.37.22",
+ "rustix 0.37.23",
]
[[package]]
@@ -2644,6 +2561,12 @@ dependencies = [
"libc",
]
+[[package]]
+name = "number_prefix"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
+
[[package]]
name = "object"
version = "0.30.4"
@@ -2752,12 +2675,6 @@ version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304"
-[[package]]
-name = "parking"
-version = "2.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e"
-
[[package]]
name = "parking_lot"
version = "0.12.1"
@@ -2828,7 +2745,7 @@ checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -2850,20 +2767,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94"
[[package]]
-name = "polling"
-version = "2.8.0"
+name = "portable-atomic"
+version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce"
-dependencies = [
- "autocfg",
- "bitflags 1.3.2",
- "cfg-if",
- "concurrent-queue",
- "libc",
- "log",
- "pin-project-lite",
- "windows-sys 0.48.0",
-]
+checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794"
[[package]]
name = "ppv-lite86"
@@ -2970,9 +2877,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.63"
+version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
+checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da"
dependencies = [
"unicode-ident",
]
@@ -3103,22 +3010,22 @@ dependencies = [
[[package]]
name = "ref-cast"
-version = "1.0.17"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "85d07b1a5f16b5548f4255a978c94259971aff73f39e8d67e8250e8b2f6667c3"
+checksum = "1641819477c319ef452a075ac34a4be92eb9ba09f6841f62d594d50fdcf0bf6b"
dependencies = [
"ref-cast-impl",
]
[[package]]
name = "ref-cast-impl"
-version = "1.0.17"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a930b010d9effee5834317bb7ff406b76af7724348fd572b38705b4bd099fa92"
+checksum = "68bf53dad9b6086826722cdc99140793afd9f62faa14a1ad07eb4f955e7a7216"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -3270,9 +3177,9 @@ dependencies = [
[[package]]
name = "rustix"
-version = "0.36.14"
+version = "0.36.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62"
+checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941"
dependencies = [
"bitflags 1.3.2",
"errno",
@@ -3284,9 +3191,9 @@ dependencies = [
[[package]]
name = "rustix"
-version = "0.37.22"
+version = "0.37.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8818fa822adcc98b18fedbb3632a6a33213c070556b5aa7c4c8cc21cff565c4c"
+checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06"
dependencies = [
"bitflags 1.3.2",
"errno",
@@ -3298,9 +3205,9 @@ dependencies = [
[[package]]
name = "rustix"
-version = "0.38.2"
+version = "0.38.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aabcb0461ebd01d6b79945797c27f8529082226cb630a9865a71870ff63532a4"
+checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4"
dependencies = [
"bitflags 2.3.3",
"errno",
@@ -3323,9 +3230,9 @@ dependencies = [
[[package]]
name = "rustls"
-version = "0.21.2"
+version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e32ca28af694bc1bbf399c33a516dbdf1c90090b8ab23c2bc24f834aa2247f5f"
+checksum = "b19faa85ecb5197342b54f987b142fb3e30d0c90da40f80ef4fa9a726e6676ed"
dependencies = [
"log",
"ring",
@@ -3356,9 +3263,9 @@ dependencies = [
[[package]]
name = "rustls-webpki"
-version = "0.100.1"
+version = "0.101.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d6207cd5ed3d8dca7816f8f3725513a34609c0c765bf652b8c3cb4cfd87db46b"
+checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e"
dependencies = [
"ring",
"untrusted",
@@ -3595,9 +3502,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scratch"
-version = "1.0.5"
+version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1"
+checksum = "764cad9e7e1ca5fe15b552859ff5d96a314e6ed2934f2260168cd5dfa5891409"
[[package]]
name = "sct"
@@ -3694,22 +3601,22 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.168"
+version = "1.0.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d614f89548720367ded108b3c843be93f3a341e22d5674ca0dd5cd57f34926af"
+checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.168"
+version = "1.0.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d4fe589678c688e44177da4f27152ee2d190757271dc7f1d5b6b9f68d869d641"
+checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -3723,6 +3630,17 @@ dependencies = [
"serde",
]
+[[package]]
+name = "serde_repr"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d89a8107374290037607734c0b73a85db7ed80cae314b3c5791f192a496e731"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.25",
+]
+
[[package]]
name = "serde_spanned"
version = "0.6.3"
@@ -3732,6 +3650,33 @@ dependencies = [
"serde",
]
+[[package]]
+name = "serde_urlencoded"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
+dependencies = [
+ "form_urlencoded",
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "serde_with"
+version = "2.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe"
+dependencies = [
+ "base64 0.13.1",
+ "chrono",
+ "hex",
+ "indexmap 1.9.3",
+ "serde",
+ "serde_json",
+ "time",
+]
+
[[package]]
name = "sha-1"
version = "0.9.8"
@@ -3833,9 +3778,9 @@ dependencies = [
[[package]]
name = "smallvec"
-version = "1.10.0"
+version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
+checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
[[package]]
name = "socket2"
@@ -3959,7 +3904,7 @@ checksum = "c7f531814d2f16995144c74428830ccf7d94ff4a7749632b83ad8199b181140c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -4090,7 +4035,7 @@ dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -4281,7 +4226,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -4361,7 +4306,7 @@ dependencies = [
"quote",
"scale-info",
"subxt-metadata",
- "syn 2.0.23",
+ "syn 2.0.25",
"thiserror",
"tokio",
]
@@ -4375,7 +4320,7 @@ dependencies = [
"darling 0.20.1",
"proc-macro-error",
"subxt-codegen",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -4404,9 +4349,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.23"
+version = "2.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737"
+checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2"
dependencies = [
"proc-macro2",
"quote",
@@ -4421,7 +4366,7 @@ checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
"unicode-xid",
]
@@ -4447,7 +4392,7 @@ dependencies = [
"cfg-if",
"fastrand",
"redox_syscall",
- "rustix 0.37.22",
+ "rustix 0.37.23",
"windows-sys 0.48.0",
]
@@ -4493,7 +4438,7 @@ checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -4506,6 +4451,33 @@ dependencies = [
"once_cell",
]
+[[package]]
+name = "time"
+version = "0.3.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446"
+dependencies = [
+ "itoa",
+ "serde",
+ "time-core",
+ "time-macros",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
+
+[[package]]
+name = "time-macros"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4"
+dependencies = [
+ "time-core",
+]
+
[[package]]
name = "tiny-bip39"
version = "1.0.0"
@@ -4566,7 +4538,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -4586,7 +4558,7 @@ version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
dependencies = [
- "rustls 0.21.2",
+ "rustls 0.21.3",
"tokio",
]
@@ -4685,7 +4657,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
@@ -4868,6 +4840,16 @@ dependencies = [
"serde",
]
+[[package]]
+name = "users"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032"
+dependencies = [
+ "libc",
+ "log",
+]
+
[[package]]
name = "utf8parse"
version = "0.2.1"
@@ -4886,12 +4868,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
-[[package]]
-name = "value-bag"
-version = "1.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d92ccd67fb88503048c01b59152a04effd0782d035a83a6d256ce6085f08f4a3"
-
[[package]]
name = "version_check"
version = "0.9.4"
@@ -4930,12 +4906,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "waker-fn"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
-
[[package]]
name = "walkdir"
version = "2.3.3"
@@ -4988,22 +4958,10 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
"wasm-bindgen-shared",
]
-[[package]]
-name = "wasm-bindgen-futures"
-version = "0.4.37"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03"
-dependencies = [
- "cfg-if",
- "js-sys",
- "wasm-bindgen",
- "web-sys",
-]
-
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.87"
@@ -5022,7 +4980,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -5196,7 +5154,7 @@ dependencies = [
"memoffset",
"paste",
"rand 0.8.5",
- "rustix 0.36.14",
+ "rustix 0.36.15",
"wasmtime-asm-macros",
"wasmtime-environ",
"wasmtime-jit-debug",
@@ -5429,9 +5387,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
name = "winnow"
-version = "0.4.7"
+version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448"
+checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529"
dependencies = [
"memchr",
]
@@ -5480,7 +5438,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.23",
+ "syn 2.0.25",
]
[[package]]
diff --git a/README.md b/README.md
index a793c74d2..98e3e1ad5 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -76,6 +79,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
diff --git a/build-image/.dockerignore b/build-image/.dockerignore
new file mode 100644
index 000000000..2f7896d1d
--- /dev/null
+++ b/build-image/.dockerignore
@@ -0,0 +1 @@
+target/
diff --git a/build-image/Dockerfile b/build-image/Dockerfile
new file mode 100644
index 000000000..94e8b4eba
--- /dev/null
+++ b/build-image/Dockerfile
@@ -0,0 +1,111 @@
+FROM docker.io/bitnami/minideb:bullseye-amd64 as slimmed-rust
+
+# The rust version to use
+# The 1.69 toolchain is temporarily required to build ink! contracts because of
+# https://github.com/paritytech/cargo-contract/issues/1139
+ARG RUST_VERSION=1.69
+# The cargo contract version to use
+ARG CARGO_CONTRACT_VERSION=3.0.1
+# Url to the cargo-contract repository to install from
+ARG CARGO_CONTRACT_GIT
+# Branch to use in git repository
+ARG CARGO_CONTRACT_BRANCH
+# Commit to use in git repository
+ARG CARGO_CONTRACT_REV
+# Tag to use in git repository
+ARG CARGO_CONTRACT_TAG
+# gcc package version
+ARG GCC_VERSION=4:10.2.1-1
+# wget package version
+ARG WGET_VERSION=1.21-1+deb11u1
+# g++ package version
+ARG G_VERSION=4:10.2.1-1
+ARG MUSL_V=1.2.2-1
+
+# metadata
+LABEL io.parity.image.vendor="Parity Technologies" \
+ io.parity.image.title="paritytech/contracts-verifiable" \
+ 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" \
+ io.parity.version.rust=${RUST_VERSION} \
+ io.parity.version.cargo-contract.version=${CARGO_CONTRACT_VERSION} \
+ io.parity.version.cargo-contract.git.repository=${CARGO_CONTRACT_GIT} \
+ io.parity.version.cargo-contract.git.branch=${CARGO_CONTRACT_BRANCH} \
+ io.parity.version.cargo-contract.git.revision=${CARGO_CONTRACT_REV} \
+ io.parity.version.cargo-contract.git.tag=${CARGO_CONTRACT_TAG} \
+ io.parity.version.gcc=${GCC_VERSION} \
+ io.parity.version.wget=${WGET_VERSION} \
+ io.parity.version.g_plus_plus=${G_VERSION} \
+ io.parity.version.musl=${MUSL_V}
+
+ENV RUSTUP_HOME=/usr/local/rustup \
+ CARGO_HOME=/usr/local/cargo \
+ PATH=/usr/local/cargo/bin:$PATH
+
+# Minimal Rust dependencies.
+RUN set -eux \
+ && apt-get update && apt-get -y install wget=${WGET_VERSION} \
+ && 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=${GCC_VERSION} \
+ && rm -rf /var/lib/apt/lists/*
+
+FROM slimmed-rust as cc-builder
+ARG CARGO_CONTRACT_VERSION
+ARG GCC_VERSION
+ARG G_VERSION
+ARG MUSL_V
+ARG CARGO_CONTRACT_BRANCH
+ARG CARGO_CONTRACT_TAG
+ARG CARGO_CONTRACT_REV
+ARG CARGO_CONTRACT_GIT
+
+# This is important, see https://github.com/rust-lang/docker-rust/issues/85
+ENV RUSTFLAGS="-C target-feature=-crt-static"
+
+# Install required packages for `cargo-contract`
+RUN apt-get -y update && apt-get -y install gcc=${GCC_VERSION} g++=${G_VERSION} musl-dev=${MUSL_V} \
+ # Install cargo contract from git if the arg is set
+ && if [ -n "$CARGO_CONTRACT_GIT" ]; then \
+ COMMAND="cargo install --git ${CARGO_CONTRACT_GIT}" ; \
+ else \
+ COMMAND="cargo install cargo-contract --locked --version ${CARGO_CONTRACT_VERSION}" ;\
+ fi \
+ && if [ -n "$CARGO_CONTRACT_BRANCH" ] && [ -n "$CARGO_CONTRACT_GIT" ]; then \
+ COMMAND="${COMMAND} --branch ${CARGO_CONTRACT_BRANCH}" ; \
+ fi \
+ && if [ -n "$CARGO_CONTRACT_REV" ] && [ -n "$CARGO_CONTRACT_GIT" ]; then \
+ COMMAND="${COMMAND} --rev ${CARGO_CONTRACT_REV}" ; \
+ fi \
+ && if [ -n "$CARGO_CONTRACT_TAG" ] && [ -n "$CARGO_CONTRACT_GIT" ]; then \
+ COMMAND="cargo install --git ${CARGO_CONTRACT_GIT} --tag ${CARGO_CONTRACT_TAG}" ; \
+ fi \
+ && echo "Executing ${COMMAND}" \
+ && eval "${COMMAND}" \
+ # Cleanup after `cargo install`
+ && rm -rf ${CARGO_HOME}/"registry" ${CARGO_HOME}/"git" /root/.cache/sccache \
+ # apt clean up
+ && apt-get remove -y gnupg \
+ && apt-get autoremove -y \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+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"]
diff --git a/build-image/README.md b/build-image/README.md
new file mode 100644
index 000000000..241da3394
--- /dev/null
+++ b/build-image/README.md
@@ -0,0 +1,52 @@
+# Verifiable builds using Docker
+
+Docker image based on the minimalistic Debian image `bitnami/minideb:bullseye-amd64`.
+
+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
+```
+
+For multi-contract projects, like in the example below:
+```
+my-app/
+├─ ink-project-a/
+│ ├─ Cargo.toml
+│ ├─ lib.rs
+├─ ink-project-b/
+│ ├─ Cargo.toml
+│ ├─ lib.rs
+├─ rust-toolchain
+```
+Make sure to run the command inside `my-app` directory and specify a relative manifest path
+to the root contract:
+`cargo contract build --verifiable --release --manifest-path ink-project-a/Cargo.toml`
+
+
+**Apple Silicon performance**
+
+It is a known issue that running AMD64 image on the ARM host architecture significantly impacts the performance
+and build times. To solve this issues, enable _Use Rosetta for x86/amd64 emulation on Apple Silicon_ in
+_Settings_ -> _Features in development_ tab in Docker Desktop App.
diff --git a/crates/build/Cargo.toml b/crates/build/Cargo.toml
index 472605ebb..5ef8df051 100644
--- a/crates/build/Cargo.toml
+++ b/crates/build/Cargo.toml
@@ -14,6 +14,7 @@ keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE", "build.rs", "templates", "riscv_memory_layout.ld"]
[dependencies]
+regex = "1"
anyhow = "1.0.71"
blake2 = "0.10.6"
cargo_metadata = "0.15.4"
@@ -38,9 +39,16 @@ wasm-opt = "0.113.0"
which = "4.4.0"
zip = { version = "0.6.6", default-features = false }
strum = { version = "0.25", features = ["derive"] }
+tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
+tokio-stream = "0.1"
+bollard = "0.14"
+indicatif = "0.17"
contract-metadata = { version = "3.0.1", path = "../metadata" }
+[target.'cfg(unix)'.dependencies]
+users = "0.11"
+
[build-dependencies]
anyhow = "1.0.71"
walkdir = "2.3.3"
diff --git a/crates/build/README.md b/crates/build/README.md
index ad051ff54..b8feec1ad 100644
--- a/crates/build/README.md
+++ b/crates/build/README.md
@@ -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
@@ -17,6 +17,7 @@ use contract_build::{
OutputType,
UnstableFlags,
Target,
+ ImageVariant,
};
let manifest_path = ManifestPath::new("my-contract/Cargo.toml").unwrap();
@@ -36,7 +37,8 @@ let args = contract_build::ExecuteArgs {
skip_wasm_validation: false,
target: Target::Wasm,
max_memory_pages: 16,
+ image: ImageVariant::Default,
};
contract_build::execute(args);
-```
\ No newline at end of file
+```
diff --git a/crates/build/src/args.rs b/crates/build/src/args.rs
index 80169e082..869476af5 100644
--- a/crates/build/src/args.rs
+++ b/crates/build/src/args.rs
@@ -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]
@@ -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 {
@@ -223,8 +231,10 @@ pub enum BuildMode {
/// Functionality to output debug messages is build into the contract.
#[default]
Debug,
- /// The contract is build without any debugging functionality.
+ /// The contract is built without any debugging functionality.
Release,
+ /// the contract is built in release mode and in a deterministic environment.
+ Verifiable,
}
impl fmt::Display for BuildMode {
@@ -232,6 +242,7 @@ impl fmt::Display for BuildMode {
match self {
Self::Debug => write!(f, "debug"),
Self::Release => write!(f, "release"),
+ Self::Verifiable => write!(f, "verifiable"),
}
}
}
diff --git a/crates/build/src/docker.rs b/crates/build/src/docker.rs
new file mode 100644
index 000000000..e9c35018f
--- /dev/null
+++ b/crates/build/src/docker.rs
@@ -0,0 +1,559 @@
+// Copyright 2018-2023 Parity Technologies (UK) Ltd.
+// This file is part of cargo-contract.
+//
+// cargo-contract is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// cargo-contract is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with cargo-contract. If not, see .
+
+//! This module provides a simple interface to execute the verifiable build
+//! inside the docker container.
+//!
+//! For the correct behaviour, the docker engine must be running,
+//! and the socket to be accessible.
+//!
+//! It is also important that the docker registry contains the tag
+//! that matches the current version of this crate.
+//!
+//! The process of the build is following:
+//! 1. Pull the image from the registry or use the local copy if available
+//! 2. Parse other arguments that were passed to the host execution context
+//! 3. Calculate the digest of the command and use it
+//! to uniquely identify the container
+//! 4. If the container exists, we just start the build, if not, we create it
+//! 5. After the build, the docker container produces metadata with
+//! paths relative to its internal storage structure, we parse the file
+//! and overwrite those paths relative to the host machine.
+
+use std::{
+ collections::{
+ hash_map::DefaultHasher,
+ HashMap,
+ },
+ hash::{
+ Hash,
+ Hasher,
+ },
+ io::{
+ BufReader,
+ Write,
+ },
+ path::Path,
+ time::Duration,
+};
+
+use anyhow::{
+ Context,
+ Result,
+};
+use bollard::{
+ container::{
+ AttachContainerOptions,
+ AttachContainerResults,
+ Config,
+ CreateContainerOptions,
+ ListContainersOptions,
+ LogOutput,
+ },
+ image::{
+ CreateImageOptions,
+ ListImagesOptions,
+ },
+ service::{
+ HostConfig,
+ ImageSummary,
+ Mount,
+ MountTypeEnum,
+ },
+ Docker,
+};
+use contract_metadata::ContractMetadata;
+use indicatif::{
+ ProgressBar,
+ ProgressStyle,
+};
+use tokio_stream::StreamExt;
+
+use crate::{
+ verbose_eprintln,
+ BuildArtifacts,
+ BuildResult,
+ BuildSteps,
+ CrateMetadata,
+ ExecuteArgs,
+ Verbosity,
+};
+
+use colored::Colorize;
+/// Default image to be used for the build.
+const IMAGE: &str = "paritytech/contracts-verifiable";
+/// We assume the docker image contains the same tag as the current version of the crate.
+const VERSION: &str = env!("CARGO_PKG_VERSION");
+/// The default directory to be mounted in the container.
+const MOUNT_DIR: &str = "/contract";
+
+/// The image to be used.
+#[derive(Clone, Debug, Default)]
+pub enum ImageVariant {
+ /// The default image is used, specified in the `IMAGE` constant.
+ #[default]
+ Default,
+ /// Custom image is used.
+ Custom(String),
+}
+
+/// Launches the docker container to execute verifiable build.
+pub fn docker_build(args: ExecuteArgs) -> Result {
+ let ExecuteArgs {
+ manifest_path,
+ verbosity,
+ output_type,
+ target,
+ build_artifact,
+ image,
+ ..
+ } = args;
+ tokio::runtime::Builder::new_multi_thread()
+ .enable_all()
+ .build()?
+ .block_on(async {
+ let mut build_steps = BuildSteps::new();
+
+ build_steps.set_total_steps(3);
+ if build_artifact == BuildArtifacts::CodeOnly {
+ build_steps.set_total_steps(2);
+ }
+
+ let crate_metadata = CrateMetadata::collect(&manifest_path, target)?;
+ let host_folder = std::env::current_dir()?;
+ let args = compose_build_args()?;
+
+ let client = Docker::connect_with_socket_defaults().map_err(|e| {
+ anyhow::anyhow!("{}\nDo you have the docker engine installed in path?", e)
+ })?;
+ let _ = client.ping().await.map_err(|e| {
+ anyhow::anyhow!("{}\nIs your docker engine up and running?", e)
+ })?;
+
+ let image = match image {
+ ImageVariant::Custom(i) => i.clone(),
+ ImageVariant::Default => {
+ format!("{}:{}", IMAGE, VERSION)
+ }
+ };
+
+ let container = create_container(
+ &client,
+ args.clone(),
+ &image,
+ &crate_metadata.contract_artifact_name,
+ &host_folder,
+ &verbosity,
+ &mut build_steps,
+ )
+ .await?;
+
+ let mut build_result =
+ run_build(&client, &container, &verbosity, &mut build_steps).await?;
+
+ update_build_result(&host_folder, &mut build_result)?;
+
+ update_metadata(&build_result, &verbosity, &mut build_steps, &image, &client)
+ .await?;
+
+ build_steps.increment_current();
+ verbose_eprintln!(
+ verbosity,
+ " {} {}",
+ format!("{build_steps}").bold(),
+ "Displaying results".bright_cyan().bold(),
+ );
+
+ Ok(BuildResult {
+ output_type,
+ verbosity,
+ ..build_result
+ })
+ })
+}
+
+/// Updates `build_result` paths to the artefacts.
+fn update_build_result(host_folder: &Path, build_result: &mut BuildResult) -> Result<()> {
+ let new_path = host_folder.join(
+ build_result
+ .target_directory
+ .as_path()
+ .strip_prefix(MOUNT_DIR)?,
+ );
+ build_result.target_directory = new_path;
+
+ let new_path = build_result.dest_wasm.as_ref().map(|p| {
+ host_folder.join(
+ p.as_path()
+ .strip_prefix(MOUNT_DIR)
+ .expect("cannot strip prefix"),
+ )
+ });
+ build_result.dest_wasm = new_path;
+
+ build_result.metadata_result.as_mut().map(|m| {
+ m.dest_bundle = host_folder.join(
+ m.dest_bundle
+ .as_path()
+ .strip_prefix(MOUNT_DIR)
+ .expect("cannot strip prefix"),
+ );
+ m.dest_metadata = host_folder.join(
+ m.dest_metadata
+ .as_path()
+ .strip_prefix(MOUNT_DIR)
+ .expect("cannot strip prefix"),
+ );
+ m
+ });
+ Ok(())
+}
+
+/// Overwrites `build_result` and `image` fields in the metadata.
+async fn update_metadata(
+ build_result: &BuildResult,
+ verbosity: &Verbosity,
+ build_steps: &mut BuildSteps,
+ build_image: &str,
+ client: &Docker,
+) -> Result<()> {
+ if let Some(metadata_artifacts) = &build_result.metadata_result {
+ let mut metadata = ContractMetadata::load(&metadata_artifacts.dest_bundle)?;
+
+ let build_image = find_local_image(client, build_image.to_string())
+ .await?
+ .context("Image summary does not exist")?;
+ // find alternative unique identifier of the image, otherwise grab the digest
+ let image_tag = match build_image
+ .repo_tags
+ .iter()
+ .find(|t| !t.ends_with("latest"))
+ {
+ Some(tag) => tag.to_owned(),
+ None => build_image.id.clone(),
+ };
+
+ metadata.image = Some(image_tag);
+
+ crate::metadata::write_metadata(
+ metadata_artifacts,
+ metadata,
+ build_steps,
+ verbosity,
+ true,
+ )?;
+ }
+ Ok(())
+}
+
+/// Searches for the local copy of the docker image.
+async fn find_local_image(
+ client: &Docker,
+ image: String,
+) -> Result