Skip to content

Commit

Permalink
Merge branch 'master' into frevert-chain-extension-example-arg
Browse files Browse the repository at this point in the history
  • Loading branch information
HCastano committed Nov 23, 2021
2 parents 2d4c338 + 2ee203d commit 3fe0f2c
Show file tree
Hide file tree
Showing 23 changed files with 142 additions and 63 deletions.
26 changes: 12 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
#
# pipelines can be triggered manually in the web

default:
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure

stages:
- check
Expand Down Expand Up @@ -67,23 +74,11 @@ workflow:
- ./scripts/.ci/pre_cache.sh
- sccache -s
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
tags:
- linux-docker

.kubernetes-env: &kubernetes-env
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
tags:
- kubernetes-parity-build

Expand All @@ -108,6 +103,9 @@ workflow:
PIPELINE_TOKEN:
vault: cicd/gitlab/$CI_PROJECT_PATH/PIPELINE_TOKEN@kv
file: false
GITHUB_SSH_PRIV_KEY:
vault: cicd/gitlab/$CI_PROJECT_PATH/GITHUB_SSH_PRIV_KEY@kv
file: true

#### stage: check

Expand Down Expand Up @@ -449,10 +447,10 @@ publish-docs:
script:
- rm -rf /tmp/*
# Set git config
- rm -rf .git/config
- git config core.sshCommand "ssh -i ${GITHUB_SSH_PRIV_KEY} -F /dev/null -o StrictHostKeyChecking=no"
- git config user.email "[email protected]"
- git config user.name "${GITHUB_USER}"
- git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/ink.git"
- git config remote.origin.url "git@github.com:/paritytech/${CI_PROJECT_NAME}.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
- git fetch origin gh-pages
# saving README and docs
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ More relevant links:
If you want to have a local setup you can use our [`substrate-contracts-node`](https://github.com/paritytech/substrate-contracts-node) for a quickstart.
It's a simple Substrate blockchain which includes the Substrate module for smart contract functionality ‒ the `contracts` pallet (see [How it Works](#how-it-works) for more).

The [Canvas UI](https://paritytech.github.io/canvas-ui/#/upload) can be used to deploy your contract to a chain and interact with it.

We also have [a demonstration testnet](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fcanvas-rpc.parity.io) running.
You can request some tokens to play with from our [Faucet](https://riot.im/app/#/room/#canvas_faucet:matrix.parity.io) and deploy your contracts via the [Canvas UI](https://paritytech.github.io/canvas-ui/#/upload).

We also have a live testnet on [Rococo](https://github.com/paritytech/cumulus/#rococo-crown)
called [Canvas](https://github.com/paritytech/canvas/). Canvas is a Substrate based
parachain which supports ink! smart contracts. For further instructions on testing with
the Canvas deployment on Rococo, follow the instructions in the
[Canvas README](https://github.com/paritytech/canvas#rococo-deployment).

For both types of chains the [Canvas UI](https://paritytech.github.io/canvas-ui/#/upload)
can be used to deploy your contract to a chain and interact with it.

## Usage

Expand Down
27 changes: 16 additions & 11 deletions crates/env/src/engine/on_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,24 @@ where
where
T: scale::Encode,
{
fn inner<E: Environment>(encoded: &mut [u8]) -> <E as Environment>::Hash {
let len_encoded = encoded.len();
let mut result = <E as Environment>::Hash::clear();
let len_result = result.as_ref().len();
if len_encoded <= len_result {
result.as_mut()[..len_encoded].copy_from_slice(encoded);
} else {
let mut hash_output = <Blake2x256 as HashOutput>::Type::default();
<Blake2x256 as CryptoHash>::hash(encoded, &mut hash_output);
let copy_len = core::cmp::min(hash_output.len(), len_result);
result.as_mut()[0..copy_len].copy_from_slice(&hash_output[0..copy_len]);
}
result
}

let mut split = self.scoped_buffer.split();
let encoded = split.take_encoded(topic_value);
let len_encoded = encoded.len();
let mut result = <E as Environment>::Hash::clear();
let len_result = result.as_ref().len();
if len_encoded <= len_result {
result.as_mut()[..len_encoded].copy_from_slice(encoded);
} else {
let mut hash_output = <Blake2x256 as HashOutput>::Type::default();
<Blake2x256 as CryptoHash>::hash(encoded, &mut hash_output);
let copy_len = core::cmp::min(hash_output.len(), len_result);
result.as_mut()[0..copy_len].copy_from_slice(&hash_output[0..copy_len]);
}
let result = inner::<E>(encoded);
self.scoped_buffer.append_encoded(&result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied
|
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `NonCodecType`
note: required by a bound in `DispatchInput`
--> src/codegen/dispatch/type_check.rs:41:8
--> src/codegen/dispatch/type_check.rs
|
41 | T: scale::Decode + 'static;
| T: scale::Decode + 'static;
| ^^^^^^^^^^^^^ required by this bound in `DispatchInput`

error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied
--> tests/ui/contract/fail/constructor-input-non-codec.rs:13:9
|
13 | / pub fn constructor(_input: NonCodecType) -> Self {
14 | | Self {}
15 | | }
| |_________^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
|
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `NonCodecType`
note: required by a bound in `parity_scale_codec::Decode::decode`
--> $CARGO/parity-scale-codec-2.3.1/src/codec.rs
|
| fn decode<I: Input>(input: &mut I) -> Result<Self, Error>;
| ^^^^^ required by this bound in `parity_scale_codec::Decode::decode`
--> tests/ui/contract/fail/constructor-input-non-codec.rs:13:9
|
13 | / pub fn constructor(_input: NonCodecType) -> Self {
14 | | Self {}
15 | | }
| |_________^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
|
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `NonCodecType`

error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied
--> tests/ui/contract/fail/constructor-input-non-codec.rs:13:9
Expand All @@ -35,3 +30,8 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied
| |_________^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType`
|
= note: required because of the requirements on the impl of `Encode` for `NonCodecType`
note: required by a bound in `ExecutionInput::<ArgumentList<ArgumentListEnd, ArgumentListEnd>>::push_arg`
--> $WORKSPACE/crates/env/src/call/execution_input.rs
|
| T: scale::Encode,
| ^^^^^^^^^^^^^ required by this bound in `ExecutionInput::<ArgumentList<ArgumentListEnd, ArgumentListEnd>>::push_arg`
22 changes: 11 additions & 11 deletions crates/lang/tests/ui/contract/fail/message-input-non-codec.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ note: required by a bound in `DispatchInput`
| ^^^^^^^^^^^^^ required by this bound in `DispatchInput`

error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied
--> tests/ui/contract/fail/message-input-non-codec.rs:18:9
|
18 | pub fn message(&self, _input: NonCodecType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
|
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `NonCodecType`
note: required by a bound in `parity_scale_codec::Decode::decode`
--> $CARGO/parity-scale-codec-2.3.1/src/codec.rs
|
| fn decode<I: Input>(input: &mut I) -> Result<Self, Error>;
| ^^^^^ required by this bound in `parity_scale_codec::Decode::decode`
--> tests/ui/contract/fail/message-input-non-codec.rs:18:9
|
18 | pub fn message(&self, _input: NonCodecType) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeDecode` is not implemented for `NonCodecType`
|
= note: required because of the requirements on the impl of `parity_scale_codec::Decode` for `NonCodecType`

error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied
--> tests/ui/contract/fail/message-input-non-codec.rs:18:9
Expand All @@ -31,6 +26,11 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WrapperTypeEncode` is not implemented for `NonCodecType`
|
= note: required because of the requirements on the impl of `Encode` for `NonCodecType`
note: required by a bound in `ExecutionInput::<ArgumentList<ArgumentListEnd, ArgumentListEnd>>::push_arg`
--> $WORKSPACE/crates/env/src/call/execution_input.rs
|
| T: scale::Encode,
| ^^^^^^^^^^^^^ required by this bound in `ExecutionInput::<ArgumentList<ArgumentListEnd, ArgumentListEnd>>::push_arg`

error[E0599]: the method `fire` exists for struct `ink_env::call::CallBuilder<DefaultEnvironment, Set<ink_env::AccountId>, Unset<u64>, Unset<u128>, Set<ExecutionInput<ArgumentList<ink_env::call::utils::Argument<NonCodecType>, ArgumentList<ArgumentListEnd, ArgumentListEnd>>>>, Set<()>>`, but its trait bounds were not satisfied
--> tests/ui/contract/fail/message-input-non-codec.rs:18:9
Expand Down
19 changes: 12 additions & 7 deletions crates/lang/tests/ui/trait_def/fail/message_input_non_codec.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ note: required by a bound in `DispatchInput`
| ^^^^^^^^^^^^^ required by this bound in `DispatchInput`

error[E0277]: the trait bound `NonCodec: WrapperTypeEncode` is not satisfied
--> tests/ui/trait_def/fail/message_input_non_codec.rs:7:5
|
7 | / #[ink(message)]
8 | | fn message(&self, input: NonCodec);
| |_______________________________________^ the trait `WrapperTypeEncode` is not implemented for `NonCodec`
|
= note: required because of the requirements on the impl of `Encode` for `NonCodec`
--> tests/ui/trait_def/fail/message_input_non_codec.rs:7:5
|
7 | / #[ink(message)]
8 | | fn message(&self, input: NonCodec);
| |_______________________________________^ the trait `WrapperTypeEncode` is not implemented for `NonCodec`
|
= note: required because of the requirements on the impl of `Encode` for `NonCodec`
note: required by a bound in `ExecutionInput::<ArgumentList<ArgumentListEnd, ArgumentListEnd>>::push_arg`
--> $WORKSPACE/crates/env/src/call/execution_input.rs
|
| T: scale::Encode,
| ^^^^^^^^^^^^^ required by this bound in `ExecutionInput::<ArgumentList<ArgumentListEnd, ArgumentListEnd>>::push_arg`

error[E0599]: the method `fire` exists for struct `CallBuilder<E, Set<<E as Environment>::AccountId>, Unset<u64>, Unset<<E as Environment>::Balance>, Set<ExecutionInput<ArgumentList<ink_env::call::utils::Argument<NonCodec>, ArgumentList<ArgumentListEnd, ArgumentListEnd>>>>, Set<()>>`, but its trait bounds were not satisfied
--> tests/ui/trait_def/fail/message_input_non_codec.rs:7:5
Expand Down
4 changes: 4 additions & 0 deletions examples/contract-terminate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "contract_terminate"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/contract-transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ name = "contract_transfer"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/delegator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ name = "delegator"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/delegator/accumulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ crate-type = [
"rlib",
]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/delegator/adder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ crate-type = [
"rlib",
]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/delegator/subber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ crate-type = [
"rlib",
]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/dns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "dns"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/erc1155/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ name = "erc1155"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "erc20"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/erc721/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "erc721"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/flipper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "flipper"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/incrementer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "incrementer"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/multisig/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ name = "multisig"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/rand-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "rand_extension"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/trait-erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "trait_erc20"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
4 changes: 4 additions & 0 deletions examples/trait-flipper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ name = "trait_flipper"
path = "lib.rs"
crate-type = ["cdylib"]

# Needed until https://github.com/paritytech/ink/issues/364 is resolved.
[profile.release]
overflow-checks = false

[features]
default = ["std"]
std = [
Expand Down
Loading

0 comments on commit 3fe0f2c

Please sign in to comment.