Skip to content

Commit

Permalink
Merge branch 'use-ink:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucca authored Jun 18, 2024
2 parents f95a90f + 0cd2b89 commit 308b69e
Show file tree
Hide file tree
Showing 308 changed files with 3,572 additions and 2,790 deletions.
1 change: 1 addition & 0 deletions .config/cargo_spellcheck.dic
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ DRink
^
externalities
sandbox_client
xcm
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ assignees: ''
**Questions**

- Is this a bug concerning building of ink! smart contracts?
- If **yes** then you might instead want to file a bug report to ink!'s build tool: https://github.com/paritytech/cargo-contract
- If **yes** then you might instead want to file a bug report to ink!'s build tool: https://github.com/use-ink/cargo-contract
- Is this a bug that appears when interacting with smart contracts via the Polkadot JS browser UI?
- If **yes** then you might instead want to file a bug report to the Polkadot JS Apps project instead: https://github.com/polkadot-js/apps

Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/contract_sizes_submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fi
echo $verb
echo $pr_comments_url

ink_master_head=$(curl -s "https://api.github.com/repos/paritytech/ink/commits/master" | jq -r .sha)
ink_master_head=$(curl -s "https://api.github.com/repos/use-ink/ink/commits/master" | jq -r .sha)
head_in_branch=$(git log | grep -q $ink_master_head; echo $?)

master_ahead=""
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ env:
# this target also makes sure that we don't pull in `std` by accident (through dependencies).
# RISC-V is a modular architecture. We might switch to a different flavor with more features
# later. For example, `riscv32imc-unknown-none-elf`.
RISCV_TARGET: riscv32i-unknown-none-elf
RISCV_TARGET: riscv32ema-unknown-none-elf

concurrency:
# Cancel in-progress jobs triggered only on pull_requests
Expand Down Expand Up @@ -234,7 +234,8 @@ jobs:
- name: Check RISCV
if: ${{ matrix.type == 'RISCV' }}
env:
RUSTC_BOOTSTRAP: 1
RUSTC_BOOTSTRAP: 1
RUSTUP_TOOLCHAIN: rve-nightly
run: |
for crate in ${ALSO_WASM_CRATES}; do
cargo check --no-default-features --target $RISCV_TARGET -Zbuild-std="core,alloc" \
Expand Down Expand Up @@ -611,7 +612,8 @@ jobs:
- name: Build Contract RISCV Examples
if: ${{ matrix.type == 'RISCV' }}
env:
RUSTC_BOOTSTRAP: 1
RUSTC_BOOTSTRAP: 1
RUSTUP_TOOLCHAIN: rve-nightly
run: |
rustup component add rust-src --toolchain stable
cargo contract -V
Expand All @@ -620,7 +622,7 @@ jobs:
# - custom_allocator
# Pulls in sp-std which needlessly requires atomic pointers (TODO: Fix sp-std and enable this example)
# - call-runtime
scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/custom-allocator --ignore public/call-runtime \
scripts/for_all_contracts_exec.sh --path integration-tests --ignore public/custom-allocator --ignore public/call-runtime --ignore public/contract-xcm \
-- cargo build --manifest-path {} --no-default-features --target $RISCV_TARGET -Zbuild-std="core,alloc"
examples-docs:
Expand Down Expand Up @@ -651,7 +653,7 @@ jobs:
run: |
# `--document-private-items` needs to be in here because currently our contract macro
# puts the contract functions in a private module.
# Once https://github.com/paritytech/ink/issues/336 has been implemented we can get rid
# Once https://github.com/use-ink/ink/issues/336 has been implemented we can get rid
# of this flag.
scripts/for_all_contracts_exec.sh --path integration-tests -- cargo doc --manifest-path {} \
--document-private-items --no-deps
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ jobs:

- name: Install toolchain
id: toolchain
uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9 # Master branch, Rust up to 1.74.1
uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # Master branch, Rust up to 1.74.1
with:
toolchain: ${{ matrix.toolchain }}
components: rust-src

- name: Install cargo-dylint
uses: baptiste0928/cargo-install@94e1849646e5797d0c8b34d8e525124ae9ae1d86 # v3.0.1
uses: baptiste0928/cargo-install@9f6037ed331dcf7da101461a20656273fa72abf0 # v3.1.0
with:
crate: cargo-dylint
version: 1

- name: Install dylint-link
uses: baptiste0928/cargo-install@94e1849646e5797d0c8b34d8e525124ae9ae1d86 # v3.0.1
uses: baptiste0928/cargo-install@9f6037ed331dcf7da101461a20656273fa72abf0 # v3.1.0
with:
crate: dylint-link
version: 1
Expand All @@ -77,10 +77,10 @@ jobs:
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3

- name: Install `cargo-contract` `master`
uses: baptiste0928/cargo-install@94e1849646e5797d0c8b34d8e525124ae9ae1d86 # v3.0.1
uses: baptiste0928/cargo-install@9f6037ed331dcf7da101461a20656273fa72abf0 # v3.1.0
with:
crate: cargo-contract
git: https://github.com/paritytech/cargo-contract.git
git: https://github.com/use-ink/cargo-contract.git
branch: master

- name: Output versions
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,33 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 100
token: ${{ secrets.GH_PAGES }}

- name: Download Contract Sizes
- name: Download Docs
uses: ./.github/download-artifact
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_NAME: docs-data
DOWNLOAD_DIR: crate-docs

- name: Add key to allow access to repository
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat <<EOT >> ~/.ssh/config
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa
EOT
- name: Push docs
run: |
# Set git config
git config user.email "[email protected]"
git config user.name "paritytech-ci"
git config user.email "[email protected]"
git config user.name "actions"
git fetch origin gh-pages
# saving README and docs
cp -r ./crate-docs/ /tmp/doc/
Expand Down
32 changes: 16 additions & 16 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@ You can find the crate documentation on docs.rs or for our
`master` branch under GitHub pages. So for `ink` e.g.:

* [https://docs.rs/ink/latest/ink](https://docs.rs/ink/latest/ink) (latest published release)
* [https://paritytech.github.io/ink/ink](https://paritytech.github.io/ink/ink) (`master`)
* [https://use-ink.github.io/ink/ink](https://use-ink.github.io/ink/ink) (`master`)

ink! is composed of a number of crates that are all found in the
`crates/` folder. On a high-level those can be grouped as:

* [`ink`](https://github.com/paritytech/ink/tree/master/crates/ink):
* [`ink`](https://github.com/use-ink/ink/tree/master/crates/ink):
The ink! language itself.
* [`allocator`](https://github.com/paritytech/ink/tree/master/crates/allocator):
* [`allocator`](https://github.com/use-ink/ink/tree/master/crates/allocator):
The allocator used for dynamic memory allocation in a contract.
* [`env`](https://github.com/paritytech/ink/tree/master/crates/env):
* [`env`](https://github.com/use-ink/ink/tree/master/crates/env):
Serves two roles:
* Exposes environmental functions, like information about the caller
of a contract call or e.g. self-terminating the contract.
* Provides the connection to the [`pallet-contracts`](https://github.com/paritytech/substrate/tree/master/frame/contracts),
so anything that calls into the underlying execution engine of the smart contract.
This includes getting and setting a smart contracts storage, as well
as the mentioned environmental functions.
* [`metadata`](https://github.com/paritytech/ink/tree/master/crates/metadata):
* [`metadata`](https://github.com/use-ink/ink/tree/master/crates/metadata):
Describes the contract in a platform agnostic way, i.e. its interface
and the types, its storage layout, etc.
* [`prelude`](https://github.com/paritytech/ink/tree/master/crates/prelude):
* [`prelude`](https://github.com/use-ink/ink/tree/master/crates/prelude):
Provides an interface to typical standard library types and
functionality (like `vec` or `string`). Since contracts are run in a
`no_std` environment we provide this crate as an entrypoint for accessing
functionality of the standard library.
* [`primitives`](https://github.com/paritytech/ink/tree/master/crates/primitives):
* [`primitives`](https://github.com/use-ink/ink/tree/master/crates/primitives):
Utilities that are used internally by multiple ink! crates.
* [`storage`](https://github.com/paritytech/ink/tree/master/crates/storage):
* [`storage`](https://github.com/use-ink/ink/tree/master/crates/storage):
The collections that are available for contract developers to put in
a smart contracts storage.
* [`engine`](https://github.com/paritytech/ink/tree/master/crates/engine):
* [`engine`](https://github.com/use-ink/ink/tree/master/crates/engine):
An off-chain testing engine, it simulates a blockchain environment and allows
mocking specified conditions.
* [`e2e`](https://github.com/paritytech/ink/tree/master/crates/e2e):
* [`e2e`](https://github.com/use-ink/ink/tree/master/crates/e2e):
An end-to-end testing framework for ink! contracts. It requires a Substrate node
which includes `pallet-contracts` running in the background. The crate provides a
macro which can be used
Expand Down Expand Up @@ -84,7 +84,7 @@ crates on which `ink` relies heavily:
## Building ink! contracts

While you can build an ink! smart contract with just `cargo build`, we
recommend using our build tool [`cargo-contract`](https://github.com/paritytech/cargo-contract).
recommend using our build tool [`cargo-contract`](https://github.com/use-ink/cargo-contract).
It automatically compiles for the correct WebAssembly target
architecture and uses an optimal set of compiler flags.

Expand Down Expand Up @@ -141,9 +141,9 @@ to move data between the pallet and a smart contract.
The advantage of a static buffer is that no gas-expensive heap allocations
are necessary, all allocations are done using simple pointer arithmetic.
The implementation of this static buffer is found in
[`ink_env/src/engine/on_chain/buffer.rs`](https://github.com/paritytech/ink/blob/master/crates/env/src/engine/on_chain/buffer.rs).
[`ink_env/src/engine/on_chain/buffer.rs`](https://github.com/use-ink/ink/blob/master/crates/env/src/engine/on_chain/buffer.rs).

The methods for communicating with the pallet are found in [`ink_env/src/engine/on_chain/impls.rs`](https://github.com/paritytech/ink/blob/master/crates/env/src/engine/on_chain/impls.rs).
The methods for communicating with the pallet are found in [`ink_env/src/engine/on_chain/impls.rs`](https://github.com/use-ink/ink/blob/master/crates/env/src/engine/on_chain/impls.rs).
If you look at the implementations you'll see a common pattern of

* SCALE-encoding values on the ink! side in order to pass them as a slice
Expand Down Expand Up @@ -203,15 +203,15 @@ type as Ethereum for their `AccountId`.

The `Environment` trait is how ink! knows the concretes types of the chain
to which the contract will be deployed to.
Specifically, our `ink_env` crate defines a trait [`Environment`](https://paritytech.github.io/ink/ink_env/trait.Environment.html)
Specifically, our `ink_env` crate defines a trait [`Environment`](https://use-ink.github.io/ink/ink_env/trait.Environment.html)
which specifies the types.
By default, ink! uses the default Substrate types, the `ink_env` crate
exports an implementation of the `Environment` trait for that:
[`DefaultEnvironment`](https://paritytech.github.io/ink/ink_env/enum.DefaultEnvironment.html).
[`DefaultEnvironment`](https://use-ink.github.io/ink/ink_env/enum.DefaultEnvironment.html).

If you are developing for a chain that uses different types than the
Substrate default types you can configure a different environment in
the contract macro ([documentation here](https://paritytech.github.io/ink/ink/attr.contract.html#header-arguments)):
the contract macro ([documentation here](https://use-ink.github.io/ink/ink/attr.contract.html#header-arguments)):

```rust
#[ink::contract(env = MyCustomTypes)]
Expand Down
Loading

0 comments on commit 308b69e

Please sign in to comment.