Skip to content

Commit 1b2e7cf

Browse files
authored
Release v4.2.1 (#1808)
* Merge pull request from GHSA-853p-5678-hv8f * Handle `LangError` from `DelegateCall` * Add basic delegate E2E test * Get test working with integration flipper * Use `incrementer` for test instead * Add tests to make sure that `LangError`s can be handled * Get rid of references to the interation Flipper * Bump version numbers to `4.2.1` * Add `CHANGELOG` entry Add more info to the `CHANGELOG` * Fix doc test related to delegate call (#1809) * Mention extra `Result` return type * Try using old CI image * Bump codec version in UI tests * Add German's CHANGELOG suggestion
1 parent 55088cc commit 1b2e7cf

File tree

60 files changed

+374
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+374
-106
lines changed

.gitlab-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ variables:
2828
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
2929
# CI_IMAGE is changed to "-:staging" when the CI image gets rebuilt
3030
# read more https://github.com/paritytech/scripts/pull/244
31-
CI_IMAGE: "paritytech/ink-ci-linux:production"
31+
CI_IMAGE: "paritytech/ink-ci-linux:a1f03f4b-20230420"
3232
PURELY_STD_CRATES: "ink/codegen metadata engine e2e e2e/macro ink/ir"
3333
ALSO_WASM_CRATES: "env storage storage/traits allocator prelude primitives ink ink/macro"
3434
ALL_CRATES: "${PURELY_STD_CRATES} ${ALSO_WASM_CRATES}"

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## Version 4.2.1
10+
11+
This release contains a low-severity security related fix. Users of the `4.x` series of
12+
releases are advised to update.
13+
14+
Note that this release contains a breaking change since the API of
15+
`ink_env::invoke_contract_delegate` and `CallBuilder::try_invoke` now return an extra
16+
`ink_primitives::MessageResult` which must be handled.
17+
18+
We decided to release this breaking change as a `PATCH` release to ensure that affected
19+
users are upgrading to the fixed API.
20+
21+
See the [published advisory](https://github.com/paritytech/ink/security/advisories/GHSA-853p-5678-hv8f)
22+
for more info.
23+
24+
### Fixed
25+
- Handle `LangError` from `DelegateCall`
26+
927
## Version 4.2.0
1028

1129
### Added

crates/allocator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_allocator"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

crates/e2e/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_e2e"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>"]
55
edition = "2021"
66

@@ -15,10 +15,10 @@ categories = ["no-std", "embedded"]
1515
include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
1616

1717
[dependencies]
18-
ink_e2e_macro = { version = "4.2.0", path = "./macro" }
19-
ink = { version = "4.2.0", path = "../ink" }
20-
ink_env = { version = "4.2.0", path = "../env" }
21-
ink_primitives = { version = "4.2.0", path = "../primitives" }
18+
ink_e2e_macro = { version = "4.2.1", path = "./macro" }
19+
ink = { version = "4.2.1", path = "../ink" }
20+
ink_env = { version = "4.2.1", path = "../env" }
21+
ink_primitives = { version = "4.2.1", path = "../primitives" }
2222

2323
funty = "2.0.0"
2424
impl-serde = { version = "0.3.1", default-features = false }

crates/e2e/macro/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_e2e_macro"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>"]
55
edition = "2021"
66

@@ -19,7 +19,7 @@ name = "ink_e2e_macro"
1919
proc-macro = true
2020

2121
[dependencies]
22-
ink_ir = { version = "4.2.0", path = "../../ink/ir" }
22+
ink_ir = { version = "4.2.1", path = "../../ink/ir" }
2323
cargo_metadata = "0.15.3"
2424
contract-build = "2.0.2"
2525
derive_more = "0.99.17"

crates/engine/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_engine"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Michael Müller <[email protected]>"]
55
edition = "2021"
66

@@ -15,7 +15,7 @@ categories = ["no-std", "embedded"]
1515
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
1616

1717
[dependencies]
18-
ink_primitives = { version = "4.2.0", path = "../../crates/primitives", default-features = false }
18+
ink_primitives = { version = "4.2.1", path = "../../crates/primitives", default-features = false }
1919
scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
2020
derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
2121

crates/env/Cargo.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_env"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66
rust-version = "1.68"
@@ -16,10 +16,10 @@ categories = ["no-std", "embedded"]
1616
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
1717

1818
[dependencies]
19-
ink_allocator = { version = "4.2.0", path = "../allocator", default-features = false }
20-
ink_storage_traits = { version = "4.2.0", path = "../storage/traits", default-features = false }
21-
ink_prelude = { version = "4.2.0", path = "../prelude", default-features = false }
22-
ink_primitives = { version = "4.2.0", path = "../primitives", default-features = false }
19+
ink_allocator = { version = "4.2.1", path = "../allocator", default-features = false }
20+
ink_storage_traits = { version = "4.2.1", path = "../storage/traits", default-features = false }
21+
ink_prelude = { version = "4.2.1", path = "../prelude", default-features = false }
22+
ink_primitives = { version = "4.2.1", path = "../primitives", default-features = false }
2323

2424
scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
2525
derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
@@ -33,7 +33,7 @@ static_assertions = "1.1"
3333
rlibc = "1"
3434

3535
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
36-
ink_engine = { version = "4.2.0", path = "../engine/", optional = true }
36+
ink_engine = { version = "4.2.1", path = "../engine/", optional = true }
3737

3838
# Hashes for the off-chain environment.
3939
sha2 = { version = "0.10", optional = true }

crates/env/src/api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ where
300300
/// - If the called code execution has trapped.
301301
pub fn invoke_contract_delegate<E, Args, R>(
302302
params: &CallParams<E, DelegateCall<E>, Args, R>,
303-
) -> Result<R>
303+
) -> Result<ink_primitives::MessageResult<R>>
304304
where
305305
E: Environment,
306306
Args: scale::Encode,

crates/env/src/backend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ pub trait TypedEnvBackend: EnvBackend {
433433
fn invoke_contract_delegate<E, Args, R>(
434434
&mut self,
435435
call_data: &CallParams<E, DelegateCall<E>, Args, R>,
436-
) -> Result<R>
436+
) -> Result<ink_primitives::MessageResult<R>>
437437
where
438438
E: Environment,
439439
Args: scale::Encode,

crates/env/src/call/call_builder.rs

+21-15
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,17 @@ where
151151
///
152152
/// # Panics
153153
///
154-
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`]. If you
155-
/// want to handle those use the [`try_invoke`][`CallParams::try_invoke`] method
156-
/// instead.
154+
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`] or an
155+
/// [`ink::primitives::LangError`][`ink_primitives::LangError`]. If you want to handle
156+
/// those use the [`try_invoke`][`CallParams::try_invoke`] method instead.
157157
pub fn invoke(&self) -> R {
158-
crate::invoke_contract_delegate(self).unwrap_or_else(|env_error| {
159-
panic!("Cross-contract call failed with {env_error:?}")
160-
})
158+
crate::invoke_contract_delegate(self)
159+
.unwrap_or_else(|env_error| {
160+
panic!("Cross-contract call failed with {env_error:?}")
161+
})
162+
.unwrap_or_else(|lang_error| {
163+
panic!("Cross-contract call failed with {lang_error:?}")
164+
})
161165
}
162166

163167
/// Invoke the contract using Delegate Call semantics with the given built-up call
@@ -167,9 +171,10 @@ where
167171
///
168172
/// # Note
169173
///
170-
/// On failure this returns an [`ink::env::Error`][`crate::Error`] which can be
174+
/// On failure this returns an outer [`ink::env::Error`][`crate::Error`] or inner
175+
/// [`ink::primitives::LangError`][`ink_primitives::LangError`], both of which can be
171176
/// handled by the caller.
172-
pub fn try_invoke(&self) -> Result<R, crate::Error> {
177+
pub fn try_invoke(&self) -> Result<ink_primitives::MessageResult<R>, crate::Error> {
173178
crate::invoke_contract_delegate(self)
174179
}
175180
}
@@ -712,7 +717,7 @@ where
712717
///
713718
/// On failure this an [`ink::env::Error`][`crate::Error`] which can be handled by the
714719
/// caller.
715-
pub fn try_invoke(self) -> Result<(), Error> {
720+
pub fn try_invoke(self) -> Result<ink_primitives::MessageResult<()>, Error> {
716721
self.params().try_invoke()
717722
}
718723
}
@@ -759,9 +764,9 @@ where
759764
///
760765
/// # Panics
761766
///
762-
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`]
763-
/// If you want to handle those use the [`try_invoke`][`CallBuilder::try_invoke`]
764-
/// method instead.
767+
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`] or an
768+
/// [`ink::primitives::LangError`][`ink_primitives::LangError`]. If you want to handle
769+
/// those use the [`try_invoke`][`CallBuilder::try_invoke`] method instead.
765770
pub fn invoke(self) -> R {
766771
self.params().invoke()
767772
}
@@ -771,9 +776,10 @@ where
771776
///
772777
/// # Note
773778
///
774-
/// On failure this an [`ink::env::Error`][`crate::Error`] which can be handled by the
775-
/// caller.
776-
pub fn try_invoke(self) -> Result<R, Error> {
779+
/// On failure this returns an outer [`ink::env::Error`][`crate::Error`] or inner
780+
/// [`ink::primitives::LangError`][`ink_primitives::LangError`], both of which can be
781+
/// handled by the caller.
782+
pub fn try_invoke(self) -> Result<ink_primitives::MessageResult<R>, Error> {
777783
self.params().try_invoke()
778784
}
779785
}

crates/env/src/engine/off_chain/impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl TypedEnvBackend for EnvInstance {
453453
fn invoke_contract_delegate<E, Args, R>(
454454
&mut self,
455455
params: &CallParams<E, DelegateCall<E>, Args, R>,
456-
) -> Result<R>
456+
) -> Result<ink_primitives::MessageResult<R>>
457457
where
458458
E: Environment,
459459
Args: scale::Encode,

crates/env/src/engine/on_chain/impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl TypedEnvBackend for EnvInstance {
444444
fn invoke_contract_delegate<E, Args, R>(
445445
&mut self,
446446
params: &CallParams<E, DelegateCall<E>, Args, R>,
447-
) -> Result<R>
447+
) -> Result<ink_primitives::MessageResult<R>>
448448
where
449449
E: Environment,
450450
Args: scale::Encode,

crates/ink/Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66
rust-version = "1.63"
@@ -16,12 +16,12 @@ categories = ["no-std", "embedded"]
1616
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
1717

1818
[dependencies]
19-
ink_env = { version = "4.2.0", path = "../env", default-features = false }
20-
ink_storage = { version = "4.2.0", path = "../storage", default-features = false }
21-
ink_primitives = { version = "4.2.0", path = "../primitives", default-features = false }
22-
ink_metadata = { version = "4.2.0", path = "../metadata", default-features = false, optional = true }
23-
ink_prelude = { version = "4.2.0", path = "../prelude", default-features = false }
24-
ink_macro = { version = "4.2.0", path = "macro", default-features = false }
19+
ink_env = { version = "4.2.1", path = "../env", default-features = false }
20+
ink_storage = { version = "4.2.1", path = "../storage", default-features = false }
21+
ink_primitives = { version = "4.2.1", path = "../primitives", default-features = false }
22+
ink_metadata = { version = "4.2.1", path = "../metadata", default-features = false, optional = true }
23+
ink_prelude = { version = "4.2.1", path = "../prelude", default-features = false }
24+
ink_macro = { version = "4.2.1", path = "macro", default-features = false }
2525

2626
scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
2727
derive_more = { version = "0.99", default-features = false, features = ["from"] }

crates/ink/codegen/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_codegen"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

@@ -18,8 +18,8 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
1818
name = "ink_codegen"
1919

2020
[dependencies]
21-
ink_primitives = { version = "4.2.0", path = "../../primitives" }
22-
ir = { version = "4.2.0", package = "ink_ir", path = "../ir", default-features = false }
21+
ink_primitives = { version = "4.2.1", path = "../../primitives" }
22+
ir = { version = "4.2.1", package = "ink_ir", path = "../ir", default-features = false }
2323
quote = "1"
2424
syn = { version = "2.0", features = ["parsing", "full", "extra-traits"] }
2525
proc-macro2 = "1.0"

crates/ink/ir/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_ir"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

crates/ink/macro/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_macro"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

@@ -15,9 +15,9 @@ categories = ["no-std", "embedded"]
1515
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
1616

1717
[dependencies]
18-
ink_ir = { version = "4.2.0", path = "../ir", default-features = false }
19-
ink_codegen = { version = "4.2.0", path = "../codegen", default-features = false }
20-
ink_primitives = { version = "4.2.0", path = "../../primitives/", default-features = false }
18+
ink_ir = { version = "4.2.1", path = "../ir", default-features = false }
19+
ink_codegen = { version = "4.2.1", path = "../codegen", default-features = false }
20+
ink_primitives = { version = "4.2.1", path = "../../primitives/", default-features = false }
2121

2222
scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
2323
syn = "2"

crates/ink/src/env_access.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,10 @@ where
616616
/// .params();
617617
/// self.env()
618618
/// .invoke_contract_delegate(&call_params)
619-
/// .unwrap_or_else(|err| {
620-
/// panic!("call delegate invocation must succeed: {:?}", err)
619+
/// .unwrap_or_else(|env_err| {
620+
/// panic!("Received an error from the Environment: {:?}", env_err)
621621
/// })
622+
/// .unwrap_or_else(|lang_err| panic!("Received a `LangError`: {:?}", lang_err))
622623
/// }
623624
/// #
624625
/// # }
@@ -631,7 +632,7 @@ where
631632
pub fn invoke_contract_delegate<Args, R>(
632633
self,
633634
params: &CallParams<E, DelegateCall<E>, Args, R>,
634-
) -> Result<R>
635+
) -> Result<ink_primitives::MessageResult<R>>
635636
where
636637
Args: scale::Encode,
637638
R: scale::Decode,

crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder<DefaultEnvi
4646
= note: the following trait bounds were not satisfied:
4747
`NonCodecType: parity_scale_codec::Decode`
4848
note: the trait `parity_scale_codec::Decode` must be implemented
49-
--> $CARGO/parity-scale-codec-3.4.0/src/codec.rs
49+
--> $CARGO/parity-scale-codec-3.5.0/src/codec.rs
5050
|
5151
| pub trait Decode: Sized {
5252
| ^^^^^^^^^^^^^^^^^^^^^^^

crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder<E, Set<Call
3333
= note: the following trait bounds were not satisfied:
3434
`NonCodec: parity_scale_codec::Decode`
3535
note: the trait `parity_scale_codec::Decode` must be implemented
36-
--> $CARGO/parity-scale-codec-3.4.0/src/codec.rs
36+
--> $CARGO/parity-scale-codec-3.5.0/src/codec.rs
3737
|
3838
| pub trait Decode: Sized {
3939
| ^^^^^^^^^^^^^^^^^^^^^^^

crates/metadata/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_metadata"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

@@ -15,8 +15,8 @@ categories = ["no-std", "embedded"]
1515
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
1616

1717
[dependencies]
18-
ink_prelude = { version = "4.2.0", path = "../prelude/", default-features = false }
19-
ink_primitives = { version = "4.2.0", path = "../primitives/", default-features = false }
18+
ink_prelude = { version = "4.2.1", path = "../prelude/", default-features = false }
19+
ink_primitives = { version = "4.2.1", path = "../primitives/", default-features = false }
2020

2121
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
2222
impl-serde = "0.4.0"

crates/prelude/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_prelude"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

crates/primitives/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ink_primitives"
3-
version = "4.2.0"
3+
version = "4.2.1"
44
authors = ["Parity Technologies <[email protected]>", "Robin Freyler <[email protected]>"]
55
edition = "2021"
66

@@ -16,7 +16,7 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
1616

1717
[dependencies]
1818
derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
19-
ink_prelude = { version = "4.2.0", path = "../prelude/", default-features = false }
19+
ink_prelude = { version = "4.2.1", path = "../prelude/", default-features = false }
2020
scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
2121
scale-decode = { version = "0.5.0", default-features = false, features = ["derive"], optional = true }
2222
scale-encode = { version = "0.1.0", default-features = false, features = ["derive"], optional = true }

0 commit comments

Comments
 (0)