Skip to content

Commit

Permalink
Release v4.2.1 (#1808)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
HCastano committed Jun 14, 2023
1 parent 55088cc commit 1b2e7cf
Show file tree
Hide file tree
Showing 60 changed files with 374 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ variables:
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
# CI_IMAGE is changed to "-:staging" when the CI image gets rebuilt
# read more https://github.com/paritytech/scripts/pull/244
CI_IMAGE: "paritytech/ink-ci-linux:production"
CI_IMAGE: "paritytech/ink-ci-linux:a1f03f4b-20230420"
PURELY_STD_CRATES: "ink/codegen metadata engine e2e e2e/macro ink/ir"
ALSO_WASM_CRATES: "env storage storage/traits allocator prelude primitives ink ink/macro"
ALL_CRATES: "${PURELY_STD_CRATES} ${ALSO_WASM_CRATES}"
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## Version 4.2.1

This release contains a low-severity security related fix. Users of the `4.x` series of
releases are advised to update.

Note that this release contains a breaking change since the API of
`ink_env::invoke_contract_delegate` and `CallBuilder::try_invoke` now return an extra
`ink_primitives::MessageResult` which must be handled.

We decided to release this breaking change as a `PATCH` release to ensure that affected
users are upgrading to the fixed API.

See the [published advisory](https://github.com/paritytech/ink/security/advisories/GHSA-853p-5678-hv8f)
for more info.

### Fixed
- Handle `LangError` from `DelegateCall`

## Version 4.2.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion crates/allocator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_allocator"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

Expand Down
10 changes: 5 additions & 5 deletions crates/e2e/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_e2e"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"

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

[dependencies]
ink_e2e_macro = { version = "4.2.0", path = "./macro" }
ink = { version = "4.2.0", path = "../ink" }
ink_env = { version = "4.2.0", path = "../env" }
ink_primitives = { version = "4.2.0", path = "../primitives" }
ink_e2e_macro = { version = "4.2.1", path = "./macro" }
ink = { version = "4.2.1", path = "../ink" }
ink_env = { version = "4.2.1", path = "../env" }
ink_primitives = { version = "4.2.1", path = "../primitives" }

funty = "2.0.0"
impl-serde = { version = "0.3.1", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions crates/e2e/macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_e2e_macro"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"

Expand All @@ -19,7 +19,7 @@ name = "ink_e2e_macro"
proc-macro = true

[dependencies]
ink_ir = { version = "4.2.0", path = "../../ink/ir" }
ink_ir = { version = "4.2.1", path = "../../ink/ir" }
cargo_metadata = "0.15.3"
contract-build = "2.0.2"
derive_more = "0.99.17"
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_engine"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Michael Müller <michi@parity.io>"]
edition = "2021"

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

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

Expand Down
12 changes: 6 additions & 6 deletions crates/env/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_env"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"
rust-version = "1.68"
Expand All @@ -16,10 +16,10 @@ categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]

[dependencies]
ink_allocator = { version = "4.2.0", path = "../allocator", default-features = false }
ink_storage_traits = { version = "4.2.0", path = "../storage/traits", default-features = false }
ink_prelude = { version = "4.2.0", path = "../prelude", default-features = false }
ink_primitives = { version = "4.2.0", path = "../primitives", default-features = false }
ink_allocator = { version = "4.2.1", path = "../allocator", default-features = false }
ink_storage_traits = { version = "4.2.1", path = "../storage/traits", default-features = false }
ink_prelude = { version = "4.2.1", path = "../prelude", default-features = false }
ink_primitives = { version = "4.2.1", path = "../primitives", default-features = false }

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

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

# Hashes for the off-chain environment.
sha2 = { version = "0.10", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ where
/// - If the called code execution has trapped.
pub fn invoke_contract_delegate<E, Args, R>(
params: &CallParams<E, DelegateCall<E>, Args, R>,
) -> Result<R>
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ pub trait TypedEnvBackend: EnvBackend {
fn invoke_contract_delegate<E, Args, R>(
&mut self,
call_data: &CallParams<E, DelegateCall<E>, Args, R>,
) -> Result<R>
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
Expand Down
36 changes: 21 additions & 15 deletions crates/env/src/call/call_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,17 @@ where
///
/// # Panics
///
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`]. If you
/// want to handle those use the [`try_invoke`][`CallParams::try_invoke`] method
/// instead.
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`] or an
/// [`ink::primitives::LangError`][`ink_primitives::LangError`]. If you want to handle
/// those use the [`try_invoke`][`CallParams::try_invoke`] method instead.
pub fn invoke(&self) -> R {
crate::invoke_contract_delegate(self).unwrap_or_else(|env_error| {
panic!("Cross-contract call failed with {env_error:?}")
})
crate::invoke_contract_delegate(self)
.unwrap_or_else(|env_error| {
panic!("Cross-contract call failed with {env_error:?}")
})
.unwrap_or_else(|lang_error| {
panic!("Cross-contract call failed with {lang_error:?}")
})
}

/// Invoke the contract using Delegate Call semantics with the given built-up call
Expand All @@ -167,9 +171,10 @@ where
///
/// # Note
///
/// On failure this returns an [`ink::env::Error`][`crate::Error`] which can be
/// On failure this returns an outer [`ink::env::Error`][`crate::Error`] or inner
/// [`ink::primitives::LangError`][`ink_primitives::LangError`], both of which can be
/// handled by the caller.
pub fn try_invoke(&self) -> Result<R, crate::Error> {
pub fn try_invoke(&self) -> Result<ink_primitives::MessageResult<R>, crate::Error> {
crate::invoke_contract_delegate(self)
}
}
Expand Down Expand Up @@ -712,7 +717,7 @@ where
///
/// On failure this an [`ink::env::Error`][`crate::Error`] which can be handled by the
/// caller.
pub fn try_invoke(self) -> Result<(), Error> {
pub fn try_invoke(self) -> Result<ink_primitives::MessageResult<()>, Error> {
self.params().try_invoke()
}
}
Expand Down Expand Up @@ -759,9 +764,9 @@ where
///
/// # Panics
///
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`]
/// If you want to handle those use the [`try_invoke`][`CallBuilder::try_invoke`]
/// method instead.
/// This method panics if it encounters an [`ink::env::Error`][`crate::Error`] or an
/// [`ink::primitives::LangError`][`ink_primitives::LangError`]. If you want to handle
/// those use the [`try_invoke`][`CallBuilder::try_invoke`] method instead.
pub fn invoke(self) -> R {
self.params().invoke()
}
Expand All @@ -771,9 +776,10 @@ where
///
/// # Note
///
/// On failure this an [`ink::env::Error`][`crate::Error`] which can be handled by the
/// caller.
pub fn try_invoke(self) -> Result<R, Error> {
/// On failure this returns an outer [`ink::env::Error`][`crate::Error`] or inner
/// [`ink::primitives::LangError`][`ink_primitives::LangError`], both of which can be
/// handled by the caller.
pub fn try_invoke(self) -> Result<ink_primitives::MessageResult<R>, Error> {
self.params().try_invoke()
}
}
2 changes: 1 addition & 1 deletion crates/env/src/engine/off_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl TypedEnvBackend for EnvInstance {
fn invoke_contract_delegate<E, Args, R>(
&mut self,
params: &CallParams<E, DelegateCall<E>, Args, R>,
) -> Result<R>
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
Expand Down
2 changes: 1 addition & 1 deletion crates/env/src/engine/on_chain/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl TypedEnvBackend for EnvInstance {
fn invoke_contract_delegate<E, Args, R>(
&mut self,
params: &CallParams<E, DelegateCall<E>, Args, R>,
) -> Result<R>
) -> Result<ink_primitives::MessageResult<R>>
where
E: Environment,
Args: scale::Encode,
Expand Down
14 changes: 7 additions & 7 deletions crates/ink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"
rust-version = "1.63"
Expand All @@ -16,12 +16,12 @@ categories = ["no-std", "embedded"]
include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]

[dependencies]
ink_env = { version = "4.2.0", path = "../env", default-features = false }
ink_storage = { version = "4.2.0", path = "../storage", default-features = false }
ink_primitives = { version = "4.2.0", path = "../primitives", default-features = false }
ink_metadata = { version = "4.2.0", path = "../metadata", default-features = false, optional = true }
ink_prelude = { version = "4.2.0", path = "../prelude", default-features = false }
ink_macro = { version = "4.2.0", path = "macro", default-features = false }
ink_env = { version = "4.2.1", path = "../env", default-features = false }
ink_storage = { version = "4.2.1", path = "../storage", default-features = false }
ink_primitives = { version = "4.2.1", path = "../primitives", default-features = false }
ink_metadata = { version = "4.2.1", path = "../metadata", default-features = false, optional = true }
ink_prelude = { version = "4.2.1", path = "../prelude", default-features = false }
ink_macro = { version = "4.2.1", path = "macro", default-features = false }

scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
derive_more = { version = "0.99", default-features = false, features = ["from"] }
Expand Down
6 changes: 3 additions & 3 deletions crates/ink/codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_codegen"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

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

[dependencies]
ink_primitives = { version = "4.2.0", path = "../../primitives" }
ir = { version = "4.2.0", package = "ink_ir", path = "../ir", default-features = false }
ink_primitives = { version = "4.2.1", path = "../../primitives" }
ir = { version = "4.2.1", package = "ink_ir", path = "../ir", default-features = false }
quote = "1"
syn = { version = "2.0", features = ["parsing", "full", "extra-traits"] }
proc-macro2 = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/ink/ir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_ir"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

Expand Down
8 changes: 4 additions & 4 deletions crates/ink/macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_macro"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

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

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

scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
syn = "2"
Expand Down
7 changes: 4 additions & 3 deletions crates/ink/src/env_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,10 @@ where
/// .params();
/// self.env()
/// .invoke_contract_delegate(&call_params)
/// .unwrap_or_else(|err| {
/// panic!("call delegate invocation must succeed: {:?}", err)
/// .unwrap_or_else(|env_err| {
/// panic!("Received an error from the Environment: {:?}", env_err)
/// })
/// .unwrap_or_else(|lang_err| panic!("Received a `LangError`: {:?}", lang_err))
/// }
/// #
/// # }
Expand All @@ -631,7 +632,7 @@ where
pub fn invoke_contract_delegate<Args, R>(
self,
params: &CallParams<E, DelegateCall<E>, Args, R>,
) -> Result<R>
) -> Result<ink_primitives::MessageResult<R>>

This comment has been minimized.

Copy link
@deuszx

deuszx Jun 16, 2023

Even though it was a bugfix you changed the API in backwards incompatible way. According to semver rules, this should bump minor version, not patch.

where
Args: scale::Encode,
R: scale::Decode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder<DefaultEnvi
= note: the following trait bounds were not satisfied:
`NonCodecType: parity_scale_codec::Decode`
note: the trait `parity_scale_codec::Decode` must be implemented
--> $CARGO/parity-scale-codec-3.4.0/src/codec.rs
--> $CARGO/parity-scale-codec-3.5.0/src/codec.rs
|
| pub trait Decode: Sized {
| ^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder<E, Set<Call
= note: the following trait bounds were not satisfied:
`NonCodec: parity_scale_codec::Decode`
note: the trait `parity_scale_codec::Decode` must be implemented
--> $CARGO/parity-scale-codec-3.4.0/src/codec.rs
--> $CARGO/parity-scale-codec-3.5.0/src/codec.rs
|
| pub trait Decode: Sized {
| ^^^^^^^^^^^^^^^^^^^^^^^
6 changes: 3 additions & 3 deletions crates/metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_metadata"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

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

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

serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
impl-serde = "0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/prelude/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_prelude"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ink_primitives"
version = "4.2.0"
version = "4.2.1"
authors = ["Parity Technologies <admin@parity.io>", "Robin Freyler <robin@parity.io>"]
edition = "2021"

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

[dependencies]
derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
ink_prelude = { version = "4.2.0", path = "../prelude/", default-features = false }
ink_prelude = { version = "4.2.1", path = "../prelude/", default-features = false }
scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] }
scale-decode = { version = "0.5.0", default-features = false, features = ["derive"], optional = true }
scale-encode = { version = "0.1.0", default-features = false, features = ["derive"], optional = true }
Expand Down
Loading

0 comments on commit 1b2e7cf

Please sign in to comment.