diff --git a/.github/workflows/compiler_docker.yml b/.github/workflows/compiler_docker.yml deleted file mode 100644 index f911d33bb..000000000 --- a/.github/workflows/compiler_docker.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Compiler_Docker - -on: - push: - branches: - - main - pull_request: - -jobs: - build: - runs-on: 'ubuntu-latest' - steps: - - uses: actions/checkout@v3 - - - name: Build docker - run: docker build -f Dockerfile.compiler --tag ink-compiler . - - - name: Login to DockerHub - if: github.ref == 'refs/heads/main' && github.repository == 'paritytech/ink-playground' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USER_NAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - - name: Tag Docker image - if: github.ref == 'refs/heads/main' && github.repository == 'paritytech/ink-playground' - run: docker tag ink-compiler:latest ${{ secrets.DOCKER_USER_NAME }}/ink-compiler - - - name: Push Docker image - if: github.ref == 'refs/heads/main' && github.repository == 'paritytech/ink-playground' - run: docker push ${{ secrets.DOCKER_USER_NAME }}/ink-compiler diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 435c0a28f..56d1c10fb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -37,10 +37,10 @@ jobs: env: DOCKER_PORT: 4000 - - name: Sleep for 120s, allow Docker image to boot up + - name: Sleep for 300s, allow Docker image to boot up uses: juliangruber/sleep-action@v1 with: - time: 120s + time: 300s - name: Install docker-tests run: yarn workspace docker-tests install diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 71e77bfaa..5f34049ae 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -55,8 +55,12 @@ jobs: - name: Build run: cargo build --verbose - name: Pull docker image - run: docker pull docker.io/achimcc/ink-compiler:latest + run: docker pull docker.io/paritytech/ink-ci-linux:production - name: Tag docker image - run: docker tag docker.io/achimcc/ink-compiler:latest ink-compiler + run: docker tag docker.io/paritytech/ink-ci-linux:production ink-compiler + - name: Copy contract folder + run: mkdir ./builds && cp -R crates/contract ./builds/contract + - name: pre-build compilation cache + run: docker run --volume cache:/usr/local/cargo/registry --volume ${GITHUB_WORKSPACE}/builds:/builds --workdir /builds/contract/ ink-compiler cargo contract build --release - name: Run tests run: cargo test --workspace --exclude rust_analyzer_wasm --verbose diff --git a/Cargo.lock b/Cargo.lock index 59c7b07ee..0c9e86a76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -656,7 +656,7 @@ dependencies = [ [[package]] name = "contract" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" dependencies = [ "ink", "parity-scale-codec", @@ -983,6 +983,19 @@ dependencies = [ "syn", ] +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "expect-test" version = "1.4.0" @@ -1399,6 +1412,12 @@ dependencies = [ "url", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.13.10" @@ -1501,9 +1520,9 @@ dependencies = [ [[package]] name = "ink" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfc1a216f815f0da881250d7bff100f821d64a2e7ce08b6eccf01c32fbe95d5" +checksum = "a1b0f5ee16576ec439e45da1f09d24a7933c8c3089c94ec7078f07a82d25c5cf" dependencies = [ "derive_more", "ink_env", @@ -1517,44 +1536,47 @@ dependencies = [ [[package]] name = "ink_allocator" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d19e055fdd9ef9fa0dd930d706b4b6f546487d3fcc9d45f6ba08d9d0d7102f3" +checksum = "b36dadecdc7e33b0fe1c198b52d474ce73ccd93ffd8acd6ded02458b4a58a2d9" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "ink_codegen" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a504663904857ce2ba5e8b85fb5d8001ebff40c327f4cc06b10c2f9b403e0a99" +checksum = "231c77d70ae53ce602f9f5848e3c1ef3bc9f7ae553a09214ad6e0722f7f99d05" dependencies = [ "blake2", "derive_more", "either", + "env_logger", "heck 0.4.0", "impl-serde", "ink_ir", "ink_primitives", "itertools", + "log", "parity-scale-codec", "proc-macro2", "quote", + "serde", + "serde_json", "syn", ] [[package]] name = "ink_engine" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d732c7fef97ab91625125750c73477f0e43cb89b57e57fca4741707c2769871" +checksum = "319a74f3313698ae6d4ae5b43164a1e0efbfd45bd0f7ef689745f98f6e505998" dependencies = [ "blake2", "derive_more", "ink_primitives", "parity-scale-codec", - "rand 0.8.4", "secp256k1", "sha2", "sha3", @@ -1562,9 +1584,9 @@ dependencies = [ [[package]] name = "ink_env" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af306608913616b0b69a8293ce03423f057e3293648909ba66061f38e5794f79" +checksum = "4543d0e0e5d1d97ce1ccb225599603ab15fb9d486f692176649b43a1311a8ad7" dependencies = [ "arrayref", "blake2", @@ -1579,7 +1601,6 @@ dependencies = [ "num-traits", "parity-scale-codec", "paste", - "rand 0.8.4", "rlibc", "scale-info", "secp256k1", @@ -1590,9 +1611,9 @@ dependencies = [ [[package]] name = "ink_ir" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900a7742a319a1fee36172869397e1f6fdf60adbb6a723cd819f0a1874775056" +checksum = "faf2ee9acbf86d5b2b6342266972217b61117c6468c81bdefe23e052beb05af1" dependencies = [ "blake2", "either", @@ -1604,9 +1625,9 @@ dependencies = [ [[package]] name = "ink_macro" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbaaeaa0e16d757eb799c732737fae6d7261e8a9257d5678b75b92a4f8dc516" +checksum = "4c1e5823e6890d11e839bf1f3e49d81b0f615038d21f7f286344db9749b4994e" dependencies = [ "ink_codegen", "ink_ir", @@ -1620,9 +1641,9 @@ dependencies = [ [[package]] name = "ink_metadata" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ae8287f3ae7a9473f1b767db3da834b6875ec7ac4c105ee360a38a5b9d9538" +checksum = "caa94adad4fca9e3a79a1c5b0edc1ea2109ef56a955a57df35b2ad32c461ac21" dependencies = [ "derive_more", "impl-serde", @@ -1634,18 +1655,18 @@ dependencies = [ [[package]] name = "ink_prelude" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd0137ab1536069c7ece025498bc957b02dcaa51460dd2a4402e80521124d04" +checksum = "5962125f78304bc2b3083391cbd579125c64ce17e61b019034094faf772c915a" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "ink_primitives" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433de1b6ff673158ec18b18fc1c149f6e3fa17d76f830256a67292f6fb4bbccf" +checksum = "90f4f26208fe23e12d436917697b951252519484134a3561fe8b65a5abc97aa9" dependencies = [ "derive_more", "ink_prelude", @@ -1656,9 +1677,9 @@ dependencies = [ [[package]] name = "ink_storage" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573363ad95f7dc14c41ed3109ab856419ba02f8c433ae6ca5f1d227494260f6a" +checksum = "682c664aa58543eafc4e3d4672b7f34c270fb23d69fe41e162e7e0544b946bad" dependencies = [ "array-init", "cfg-if 1.0.0", @@ -1674,9 +1695,9 @@ dependencies = [ [[package]] name = "ink_storage_traits" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88aa73c6b8815726674ddc451afa23ec363bc0cafaef81f031e036ff3dfa9506" +checksum = "596247891eb221a0b7debce9f8cf123b9a14f23a4a10664e73ec16d9eb1e92e9" dependencies = [ "ink_metadata", "ink_prelude", @@ -3303,9 +3324,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.1.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c46be926081c9f4dd5dd9b6f1d3e3229f2360bc6502dd8836f84a93b7c75e99a" +checksum = "88d8a765117b237ef233705cc2cc4c6a27fccd46eea6ef0c8c6dae5f3ef407f8" dependencies = [ "bitvec", "cfg-if 1.0.0", @@ -3317,9 +3338,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.1.2" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e334bb10a245e28e5fd755cabcafd96cfcd167c99ae63a46924ca8d8703a3c" +checksum = "cdcd47b380d8c4541044e341dcd9475f55ba37ddc50c908d945fc036a8642496" dependencies = [ "proc-macro-crate", "proc-macro2", diff --git a/Dockerfile b/Dockerfile index cee52537d..965fc67a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -124,6 +124,9 @@ RUN apt-get --yes install docker-ce docker-ce-cli \ COPY sysbox/on-start.sh /usr/bin RUN chmod +x /usr/bin/on-start.sh +RUN mkdir /builds +COPY crates/contract /builds/contract + # Entrypoint ENTRYPOINT [ "on-start.sh" ] diff --git a/Dockerfile.compiler b/Dockerfile.compiler deleted file mode 100644 index aa956e95e..000000000 --- a/Dockerfile.compiler +++ /dev/null @@ -1,17 +0,0 @@ -ARG REGISTRY_PATH=docker.io/paritytech - -FROM ${REGISTRY_PATH}/ink-ci-linux:production - -ENV CARGO_TARGET_DIR="/target" - -# Instantiate new Contract -RUN cargo contract new contract - -# Provide Cargo.toml with all ink! dependencies -COPY crates/contract/Cargo.toml /builds/contract/Cargo.toml - -# Pre-build ink! dependencies -RUN cd contract && cargo contract build -RUN cd contract && cargo test - -WORKDIR /builds/contract diff --git a/Makefile b/Makefile index 37cd2c24f..438b8bc22 100644 --- a/Makefile +++ b/Makefile @@ -243,8 +243,9 @@ docker-shell: --runtime=sysbox-runc \ -it \ --volume /tmp:/tmp \ + --volume cache:/cache \ --entrypoint /bin/bash \ - --publish $(DOCKER_PORT):4000 \ + --publish 5000:4000 \ ink-playground docker-log: diff --git a/crates/contract/Cargo.toml b/crates/contract/Cargo.toml index ba6492cb3..ddf28607c 100755 --- a/crates/contract/Cargo.toml +++ b/crates/contract/Cargo.toml @@ -1,23 +1,20 @@ [package] name = "contract" -version = "4.0.0-alpha.3" +version = "4.0.0-beta" authors = ["Parity Technologies "] edition = "2021" publish = false [dependencies] -ink = { version = "4.0.0-alpha.3", default-features = false } +ink = { version = "4.0.0-beta", default-features = false } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } +scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } [lib] name = "contract" path = "lib.rs" -crate-type = [ - # Used for normal contract Wasm blobs. - "cdylib", -] +crate-type = ["cdylib"] [features] default = ["std"] diff --git a/crates/sandbox/src/build_command.rs b/crates/sandbox/src/build_command.rs index d2da843b1..c5c614ab5 100644 --- a/crates/sandbox/src/build_command.rs +++ b/crates/sandbox/src/build_command.rs @@ -104,6 +104,10 @@ fn build_basic_secure_docker_command() -> Command { DOCKER_WORKDIR, "--net", "none", + "--volume", + "cache:/usr/local/cargo/registry:ro", + "--volume", + "/builds:/builds", "--memory", "1024m", "--memory-swap", @@ -131,7 +135,7 @@ fn build_execution_command() -> Vec { "rm -rf {}/contract.* {}/metadata.json", target_dir, target_dir ); - let build_cmd = "cargo contract build --offline 2>&1".to_string(); + let build_cmd = "cargo contract build --release --offline 2>&1".to_string(); let move_cmd = format!("mv {}/contract.contract {}", target_dir, DOCKER_OUTPUT); let command = format!("{} && {} && {}", clean_cmd, build_cmd, move_cmd); diff --git a/sysbox/on-start.sh b/sysbox/on-start.sh index 40c2bf055..60c6b785f 100755 --- a/sysbox/on-start.sh +++ b/sysbox/on-start.sh @@ -5,9 +5,12 @@ dockerd > /var/log/dockerd.log 2>&1 & sleep 2 # pull inner images -docker pull achimcc/ink-compiler:latest -docker tag achimcc/ink-compiler ink-compiler +docker pull paritytech/ink-ci-linux:production +docker tag paritytech/ink-ci-linux:production ink-compiler +docker run --volume cache:/usr/local/cargo/registry --volume /builds:/builds --workdir /builds/contract/ ink-compiler cargo clean +docker run --volume cache:/usr/local/cargo/registry --volume /builds:/builds --workdir /builds/contract/ ink-compiler cargo contract build --release +docker run --volume cache:/usr/local/cargo/registry --volume /builds:/builds --workdir /builds/contract/ ink-compiler cargo contract test # start backend server /app/target/release/backend --port 4000 --host 0.0.0.0 --frontend_folder /app/packages/playground/dist