Skip to content

Commit

Permalink
Changing toolchain to 1.69
Browse files Browse the repository at this point in the history
  • Loading branch information
mgralinski-bright committed Jul 21, 2023
1 parent 2a3b4db commit 0fdc991
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 33 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install nightly
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-11-28
toolchain: 1.69
override: true
- name: Update Rust environment
run: rustup component add rust-src --toolchain nightly-2022-11-28-x86_64-unknown-linux-gnu
run: rustup component add rust-src --toolchain 1.69-x86_64-unknown-linux-gnu
- name: Adding WebAssembly target
run: rustup target add x86_64-unknown-linux-gnu wasm32-unknown-unknown
- name: Build bright disputes
run: cd contract && cargo +nightly-2022-11-28 build --release --verbose
run: cd contract && cargo build --release --verbose
- name: Run bright disputes unit tests
run: cd contract && cargo +nightly-2022-11-28 test --release --verbose
run: cd contract && cargo test --release --verbose
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
This project is a dApp for raising and solving the disputes on the Substrate-based blockchains. Process of building and running smart contract can be found in the sections bellow. Showcase scenario can be found in the [documentation](https://github.com/bright/bright-disputes/blob/main/doc/README.md).

## Prerequisites
1. `cargo-contract 2.x`
2. `ink-wrapper 0.4.1`
1. `cargo-contract 3.01`
2. `ink-wrapper 0.5.0`
2. `rustc-1.69`

## Build
To build smart contract run:
```
cargo +nightly-2022-11-28 contract build --release --manifest-path contract/Cargo.toml
cargo contract build --release --manifest-path contract/Cargo.toml
```
## Run
Running smart contract can be done by running `deploy.sh` script:
Expand All @@ -29,7 +30,7 @@ This will export *bright_disputes.json*, *bright_disputes.wasm*, *bright_dispute
## Tests
To run a unit test:
```
cargo +nightly-2022-11-28 test --release --manifest-path contract/Cargo.toml
cargo test --release --manifest-path contract/Cargo.toml
```
or with docker:
```
Expand All @@ -39,16 +40,16 @@ docker build -f docker/Dockerfile.testing --progress=plain .
## E2E tests
To run E2E tests on you local machine, first run a aleph-node. We can do it, by running `deploy.sh` from the running part. After that we need build contract on our local machine:
```
cargo +nightly-2022-11-28 contract build --release --manifest-path contract/Cargo.toml
cargo contract build --release --manifest-path contract/Cargo.toml
```
and upload it to the node:
```
cargo contract upload --manifest-path contract/Cargo.toml --suri //Alice --url ws://localhost:9944 || true
```
after that we need to use [ink-wrapper](https://crates.io/crates/ink-wrapper) tool to generate a type-safe code for calling smart contract from our e2e tests:
than we need to use [ink-wrapper](https://crates.io/crates/ink-wrapper) tool to generate a type-safe code for calling smart contract from our e2e tests:
```
cd tests
ink-wrapper -m ../contract/target/ink/bright_disputes.json --wasm-path ../contract/target/ink/bright_disputes.wasm | rustfmt --edition 2021 > bright_disputes.rs
ink-wrapper -m ../contract/target/ink/bright_disputes.json --wasm-path ../contract/target/ink/bright_disputes.wasm | rustfmt +nightly --edition 2021 > bright_disputes.rs
```
Finally we can run a e2e tests by calling:
```
Expand Down
3 changes: 1 addition & 2 deletions contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ publish = false

[lib]
path = "src/lib.rs"
crate-type = ["cdylib", "rlib"]

[dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
Expand All @@ -26,4 +25,4 @@ std = [
"ink/std",
"baby-liminal-extension/ink-std",
]
ink-as-dependency = []
ink-as-dependency = []
3 changes: 1 addition & 2 deletions contract/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
#![cfg_attr(not(feature = "std"), no_std, no_main)]

mod contract;
mod dispute;
Expand Down
13 changes: 7 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ ENV PATH="/root/.cargo/bin:${PATH}"

COPY . /bright_dispute/

RUN rustup target add x86_64-unknown-linux-gnu wasm32-unknown-unknown
RUN rustup install nightly-2022-11-28
RUN rustup default nightly-2022-11-28
RUN rustup component add rust-src --toolchain nightly-2022-11-28-x86_64-unknown-linux-gnu
RUN cargo install --force --locked cargo-contract --version 2.0.0
# RUN rustup update stable
RUN rustup install 1.69
RUN rustup default 1.69
RUN rustup component add rust-src --toolchain 1.69
RUN rustup target add wasm32-unknown-unknown --toolchain 1.69
RUN cargo install --force --locked cargo-contract --version 3.0.1

WORKDIR /bright_dispute/contract
RUN cargo +nightly-2022-11-28 contract build --release
RUN cargo contract build --release

FROM scratch AS export-stage
COPY --from=build /bright_dispute/contract/target/ink/bright_disputes.json .
Expand Down
12 changes: 6 additions & 6 deletions docker/Dockerfile.testing
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ ENV PATH="/root/.cargo/bin:${PATH}"

COPY . /bright_dispute/

RUN rustup target add x86_64-unknown-linux-gnu wasm32-unknown-unknown
RUN rustup install nightly-2022-11-28
RUN rustup default nightly-2022-11-28
RUN rustup component add rust-src --toolchain nightly-2022-11-28-x86_64-unknown-linux-gnu
RUN cargo install --force --locked cargo-contract --version 2.0.0
RUN rustup install 1.69
RUN rustup default 1.69
RUN rustup component add rust-src --toolchain 1.69
RUN rustup target add wasm32-unknown-unknown --toolchain 1.69
RUN cargo install --force --locked cargo-contract --version 3.0.1

WORKDIR /bright_dispute/contract
RUN cargo +nightly-2022-11-28 test --release
RUN cargo test --release
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

8 changes: 4 additions & 4 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ CARGO_TOML="${SCRIPT_DIR}"/../contract/Cargo.toml

# Run unit tests
cd "${SCRIPT_DIR}"/../contract
cargo +nightly test --release
cargo test --release

# Run e2e tests
cd "${SCRIPT_DIR}"/../tests
cargo +nightly-2022-11-28 contract build --release --manifest-path "${CARGO_TOML}"
cargo contract build --release --manifest-path "${CARGO_TOML}"
cargo contract upload --manifest-path "${CARGO_TOML}" --suri //Alice --url ws://localhost:9944 || true
ink-wrapper -m "${SCRIPT_DIR}"/../contract/target/ink/bright_disputes.json --wasm-path "${SCRIPT_DIR}"/../contract/target/ink/bright_disputes.wasm | rustfmt --edition 2021 > "${SCRIPT_DIR}"/../tests/bright_disputes.rs
cargo +nightly-2022-11-28 test --release
ink-wrapper -m "${SCRIPT_DIR}"/../contract/target/ink/bright_disputes.json --wasm-path "${SCRIPT_DIR}"/../contract/target/ink/bright_disputes.wasm | rustfmt +nightly --edition 2021 > "${SCRIPT_DIR}"/../tests/bright_disputes.rs
cargo +nightly test --release
6 changes: 6 additions & 0 deletions tests/bright_disputes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ impl ink_wrapper_types::EventSource for Instance {
type Event = event::Event;
}

#[allow(dead_code)]
pub fn upload() -> ink_wrapper_types::UploadCall {
let wasm = include_bytes!("../contract/target/ink/bright_disputes.wasm");
ink_wrapper_types::UploadCall::new(wasm.to_vec(), CODE_HASH)
}

impl Instance {
/// Constructor
#[allow(dead_code, clippy::too_many_arguments)]
Expand Down

0 comments on commit 0fdc991

Please sign in to comment.