diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 985fcf1f35..57cdca8999 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,7 @@ variables: GIT_DEPTH: 100 CARGO_INCREMENTAL: 0 CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}" - CI_IMAGE: "paritytech/ci-unified:bullseye-1.69.0-2023-03-21" + CI_IMAGE: "paritytech/ci-unified:bullseye-1.71.0-2023-05-23" 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}" diff --git a/Cargo.toml b/Cargo.toml index dadd4dc479..66c5a1cd3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,8 @@ serde_json = { version = "1.0.81" } sha2 = { version = "0.10" } sha3 = { version = "0.10" } static_assertions = { version = "1.1" } -subxt = { version = "0.29.0" } +subxt = { version = "0.30.1" } +subxt-signer = { version = "0.30.1" } syn = { version = "2" } synstructure = { version = "0.13.0" } tokio = { version = "1.18.2" } diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index 867f7fd310..b8a916d21e 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -30,6 +30,7 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } scale = { package = "parity-scale-codec", workspace = true } subxt = { workspace = true } +subxt-signer = { workspace = true, features = ["subxt", "sr25519"] } # Substrate pallet-contracts-primitives = { workspace = true } diff --git a/crates/e2e/macro/src/codegen.rs b/crates/e2e/macro/src/codegen.rs index fb81939c4c..6cf9c16899 100644 --- a/crates/e2e/macro/src/codegen.rs +++ b/crates/e2e/macro/src/codegen.rs @@ -293,6 +293,7 @@ fn build_contract(path_to_cargo_toml: &str) -> String { output_type: OutputType::HumanReadable, skip_wasm_validation: false, target: Target::Wasm, + ..ExecuteArgs::default() }; match contract_build::execute(args) { diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index 7d4c56f3af..caac116024 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -27,7 +27,7 @@ use super::{ sr25519, ContractInstantiateResult, ContractsApi, - Signer, + Keypair, }; use crate::contract_results::{ CallDryRunResult, @@ -46,7 +46,6 @@ use ink_env::{ }, Environment, }; -use sp_core::Pair; #[cfg(feature = "std")] use std::{ collections::BTreeMap, @@ -64,7 +63,7 @@ use subxt::{ Value, ValueDef, }, - tx::PairSigner, + tx::Signer, }; pub type Error = crate::error::Error< @@ -98,12 +97,11 @@ where impl Client where C: subxt::Config, - C::AccountId: From - + scale::Codec - + serde::de::DeserializeOwned - + Debug, + C::AccountId: + From + scale::Codec + serde::de::DeserializeOwned + Debug, + C::Address: From, C::Signature: From, - >::OtherParams: Default, + >::OtherParams: Default, E: Environment, E::AccountId: Debug, @@ -139,17 +137,20 @@ where /// number of times. pub async fn create_and_fund_account( &self, - origin: &Signer, + origin: &Keypair, amount: E::Balance, - ) -> Signer + ) -> Keypair where E::Balance: Clone, C::AccountId: Clone + core::fmt::Display + Debug, - C::AccountId: From, { - let (pair, _, _) = ::generate_with_phrase(None); - let pair_signer = PairSigner::::new(pair); - let account_id = pair_signer.account_id().to_owned(); + let (_, phrase, _) = + ::generate_with_phrase(None); + let phrase = + subxt_signer::bip39::Mnemonic::parse(phrase).expect("valid phrase expected"); + let keypair = Keypair::from_phrase(&phrase, None).expect("valid phrase expected"); + let account_id = >::account_id(&keypair); + let origin_account_id = origin.public_key().to_account_id(); self.api .try_transfer_balance(origin, account_id.clone(), amount) @@ -157,19 +158,16 @@ where .unwrap_or_else(|err| { panic!( "transfer from {} to {} failed with {:?}", - origin.account_id(), - account_id, - err + origin_account_id, account_id, err ) }); log_info(&format!( "transfer from {} to {} succeeded", - origin.account_id(), - account_id, + origin_account_id, account_id, )); - pair_signer + keypair } /// This function extracts the metadata of the contract at the file path @@ -183,7 +181,7 @@ where pub async fn instantiate( &mut self, contract_name: &str, - signer: &Signer, + signer: &Keypair, constructor: CreateBuilderPartial, value: E::Balance, storage_deposit_limit: Option, @@ -209,7 +207,7 @@ where pub async fn instantiate_dry_run( &mut self, contract_name: &str, - signer: &Signer, + signer: &Keypair, constructor: CreateBuilderPartial, value: E::Balance, storage_deposit_limit: Option, @@ -256,7 +254,7 @@ where /// Executes an `instantiate_with_code` call and captures the resulting events. async fn exec_instantiate( &mut self, - signer: &Signer, + signer: &Keypair, code: Vec, constructor: CreateBuilderPartial, value: E::Balance, @@ -368,7 +366,7 @@ where pub async fn upload( &mut self, contract_name: &str, - signer: &Signer, + signer: &Keypair, storage_deposit_limit: Option, ) -> Result>, Error> { let code = self.load_code(contract_name); @@ -382,7 +380,7 @@ where /// Executes an `upload` call and captures the resulting events. pub async fn exec_upload( &mut self, - signer: &Signer, + signer: &Keypair, code: Vec, storage_deposit_limit: Option, ) -> Result>, Error> { @@ -453,7 +451,7 @@ where /// contains all events that are associated with this transaction. pub async fn call( &mut self, - signer: &Signer, + signer: &Keypair, message: &CallBuilderFinal, value: E::Balance, storage_deposit_limit: Option, @@ -519,7 +517,7 @@ where /// contains all events that are associated with this transaction. pub async fn runtime_call<'a>( &mut self, - signer: &Signer, + signer: &Keypair, pallet_name: &'a str, call_name: &'a str, call_data: Vec, @@ -554,7 +552,7 @@ where /// invoked message. pub async fn call_dry_run( &mut self, - signer: &Signer, + signer: &Keypair, message: &CallBuilderFinal, value: E::Balance, storage_deposit_limit: Option, @@ -570,7 +568,7 @@ where let exec_result = self .api .call_dry_run( - Signer::account_id(signer).clone(), + Signer::::account_id(signer), dest, exec_input, value, diff --git a/crates/e2e/src/default_accounts.rs b/crates/e2e/src/default_accounts.rs deleted file mode 100644 index fe8349d887..0000000000 --- a/crates/e2e/src/default_accounts.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2018-2022 Parity Technologies (UK) Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Default accounts provided by [`sp_keyring::sr25519::Keyring`]. - -use super::{ - AccountKeyring, - PairSigner, -}; -use sp_core::sr25519; - -#[rustfmt::skip] -macro_rules! default_account { - ($fn_name:ident $keyring_fn_name:ident) => { - #[doc = concat!( - "Returns the default [`sp_keyring::sr25519::Keyring`] for `//", - stringify!($keyring_fn_name), - "`." - )] - pub fn $fn_name() -> PairSigner - where - C: subxt::Config, - C::Signature: From, - C::AccountId: From - { - PairSigner::new(AccountKeyring::$keyring_fn_name.pair()) - } - }; -} - -// The following accounts are pre-defined in [`sp-keyring::sr25519`]. -default_account!(alice Alice); -default_account!(bob Bob); -default_account!(charlie Charlie); -default_account!(dave Dave); -default_account!(eve Eve); -default_account!(ferdie Ferdie); -default_account!(one One); -default_account!(two Two); diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 8da67d3724..2bf46f4d06 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -22,7 +22,6 @@ mod builders; mod client; mod contract_results; -mod default_accounts; mod error; pub mod events; mod node_proc; @@ -39,7 +38,6 @@ pub use contract_results::{ InstantiationResult, UploadResult, }; -pub use default_accounts::*; pub use ink_e2e_macro::test; pub use node_proc::{ TestNodeProcess, @@ -47,9 +45,11 @@ pub use node_proc::{ }; pub use sp_core::H256; pub use sp_keyring::AccountKeyring; -pub use subxt::{ +pub use subxt; +pub use subxt_signer::sr25519::{ self, - tx::PairSigner, + dev::*, + Keypair, }; pub use tokio; pub use tracing_subscriber; @@ -58,7 +58,6 @@ use pallet_contracts_primitives::{ ContractExecResult, ContractInstantiateResult, }; -use sp_core::sr25519; use std::{ cell::RefCell, sync::Once, @@ -67,12 +66,6 @@ use xts::ContractsApi; pub use subxt::PolkadotConfig; -/// Signer that is used throughout the E2E testing. -/// -/// The E2E testing can only be used with nodes that support `sr25519` -/// cryptography. -pub type Signer = PairSigner; - /// We use this to only initialize `env_logger` once. pub static INIT: Once = Once::new(); diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index 49e9245dbd..1aeee3907f 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -17,7 +17,7 @@ use super::{ sr25519, ContractExecResult, ContractInstantiateResult, - Signer, + Keypair, }; use ink_env::Environment; @@ -32,6 +32,7 @@ use subxt::{ config::ExtrinsicParams, ext::scale_encode, rpc_params, + tx::Signer, utils::MultiAddress, OnlineClient, }; @@ -209,10 +210,10 @@ pub struct ContractsApi { impl ContractsApi where C: subxt::Config, - C::AccountId: serde::de::DeserializeOwned, - C::AccountId: scale::Codec, + C::AccountId: From + serde::de::DeserializeOwned + scale::Codec, + C::Address: From, C::Signature: From, - >::OtherParams: Default, + >::OtherParams: Default, E: Environment, E::Balance: scale::HasCompact + serde::Serialize, @@ -231,7 +232,7 @@ where /// invalid (e.g. out of date nonce) pub async fn try_transfer_balance( &self, - origin: &Signer, + origin: &Keypair, dest: C::AccountId, value: E::Balance, ) -> Result<(), subxt::Error> { @@ -266,11 +267,11 @@ where code: Vec, data: Vec, salt: Vec, - signer: &Signer, + signer: &Keypair, ) -> ContractInstantiateResult { let code = Code::Upload(code); let call_request = RpcInstantiateRequest:: { - origin: subxt::tx::Signer::account_id(signer).clone(), + origin: Signer::::account_id(signer), value, gas_limit: None, storage_deposit_limit, @@ -297,7 +298,7 @@ where pub async fn submit_extrinsic( &self, call: &Call, - signer: &Signer, + signer: &Keypair, ) -> ExtrinsicEvents where Call: subxt::tx::TxPayload, @@ -341,7 +342,7 @@ where code: Vec, data: Vec, salt: Vec, - signer: &Signer, + signer: &Keypair, ) -> ExtrinsicEvents { let call = subxt::tx::Payload::new( "Contracts", @@ -363,12 +364,12 @@ where /// Dry runs the upload of the given `code`. pub async fn upload_dry_run( &self, - signer: &Signer, + signer: &Keypair, code: Vec, storage_deposit_limit: Option, ) -> CodeUploadResult { let call_request = RpcCodeUploadRequest:: { - origin: subxt::tx::Signer::account_id(signer).clone(), + origin: Signer::::account_id(signer), code, storage_deposit_limit, determinism: Determinism::Enforced, @@ -393,7 +394,7 @@ where /// contains all events that are associated with this transaction. pub async fn upload( &self, - signer: &Signer, + signer: &Keypair, code: Vec, storage_deposit_limit: Option, ) -> ExtrinsicEvents { @@ -453,7 +454,7 @@ where gas_limit: Weight, storage_deposit_limit: Option, data: Vec, - signer: &Signer, + signer: &Keypair, ) -> ExtrinsicEvents { let call = subxt::tx::Payload::new( "Contracts", @@ -479,7 +480,7 @@ where /// contains all events that are associated with this transaction. pub async fn runtime_call<'a>( &self, - signer: &Signer, + signer: &Keypair, pallet_name: &'a str, call_name: &'a str, call_data: Vec, diff --git a/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr b/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr index 84471d5f79..2218f22a1c 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr @@ -12,6 +12,9 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied note: required by a bound in `DispatchInput` --> src/codegen/dispatch/type_check.rs | + | pub struct DispatchInput(T) + | ------------- required by a bound in this struct + | where | T: scale::Decode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchInput` @@ -50,5 +53,8 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution_input.rs | + | pub fn push_arg( + | -------- required by a bound in this associated function +... | T: scale::Encode, | ^^^^^^^^^^^^^ required by this bound in `ExecutionInput::>::push_arg` diff --git a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr index 0fcf8ce9f4..0907502d5a 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr @@ -8,6 +8,9 @@ error[E0277]: the trait bound `Result, LangError>: note: required by a bound in `return_value` --> $WORKSPACE/crates/env/src/api.rs | + | pub fn return_value(return_flags: ReturnFlags, return_value: &R) -> ! + | ------------ required by a bound in this function + | where | R: scale::Encode, | ^^^^^^^^^^^^^ required by this bound in `return_value` @@ -26,6 +29,9 @@ error[E0277]: the trait bound `contract::Error: WrapperTypeDecode` is not satisf note: required by a bound in `CreateBuilder::>>::returns` --> $WORKSPACE/crates/env/src/call/create_builder.rs | + | pub fn returns( + | ------- required by a bound in this associated function +... | R: ConstructorReturnType, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `CreateBuilder::>>::returns` @@ -51,5 +57,8 @@ error[E0277]: the trait bound `contract::Error: TypeInfo` is not satisfied note: required by a bound in `TypeSpec::with_name_str` --> $WORKSPACE/crates/metadata/src/specs.rs | + | pub fn with_name_str(display_name: &'static str) -> Self + | ------------- required by a bound in this associated function + | where | T: TypeInfo + 'static, | ^^^^^^^^ required by this bound in `TypeSpec::with_name_str` diff --git a/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr b/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr index 33dee25041..cc74017436 100644 --- a/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr +++ b/crates/ink/tests/ui/contract/fail/impl-block-using-env-no-marker.stderr @@ -7,5 +7,5 @@ error[E0599]: no method named `env` found for reference `&Contract` in the curre = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -1 | use ink::codegen::Env; +1 + use ink::codegen::Env; | diff --git a/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr b/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr index 24dfe00bc5..3ac2382e77 100644 --- a/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr +++ b/crates/ink/tests/ui/contract/fail/impl-block-using-static-env-no-marker.stderr @@ -10,5 +10,5 @@ error[E0599]: no function or associated item named `env` found for struct `Contr = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -1 | use ink::codegen::StaticEnv; +1 + use ink::codegen::StaticEnv; | diff --git a/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr index 29c65d9615..3e407002f5 100644 --- a/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr @@ -12,6 +12,9 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied note: required by a bound in `DispatchInput` --> src/codegen/dispatch/type_check.rs | + | pub struct DispatchInput(T) + | ------------- required by a bound in this struct + | where | T: scale::Decode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchInput` @@ -50,6 +53,9 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution_input.rs | + | pub fn push_arg( + | -------- required by a bound in this associated function +... | T: scale::Encode, | ^^^^^^^^^^^^^ required by this bound in `ExecutionInput::>::push_arg` @@ -65,4 +71,4 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder, ArgumentList>: Encode` + `ArgumentList, ArgumentList>: Encode` diff --git a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr index 0dd6d58679..877500181f 100644 --- a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr @@ -18,6 +18,9 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied note: required by a bound in `DispatchOutput` --> src/codegen/dispatch/type_check.rs | + | pub struct DispatchOutput(T) + | -------------- required by a bound in this struct + | where | T: scale::Encode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchOutput` @@ -31,6 +34,9 @@ error[E0277]: the trait bound `Result: Encode` is not s note: required by a bound in `return_value` --> $WORKSPACE/crates/env/src/api.rs | + | pub fn return_value(return_flags: ReturnFlags, return_value: &R) -> ! + | ------------ required by a bound in this function + | where | R: scale::Encode, | ^^^^^^^^^^^^^ required by this bound in `return_value` diff --git a/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr index 4d2a1e4027..5ec79abc41 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr @@ -12,6 +12,9 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeDecode` is not satisfied note: required by a bound in `DispatchInput` --> src/codegen/dispatch/type_check.rs | + | pub struct DispatchInput(T) + | ------------- required by a bound in this struct + | where | T: scale::Decode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchInput` @@ -38,6 +41,9 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeEncode` is not satisfied note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution_input.rs | + | pub fn push_arg( + | -------- required by a bound in this associated function +... | T: scale::Encode, | ^^^^^^^^^^^^^ required by this bound in `ExecutionInput::>::push_arg` @@ -45,9 +51,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder tests/ui/trait_def/fail/message_input_non_codec.rs:5:5 | 5 | #[ink(message)] - | ^ - | | - | method cannot be called due to unsatisfied trait bounds + | ^ method cannot be called due to unsatisfied trait bounds | ::: $WORKSPACE/crates/env/src/call/execution_input.rs | @@ -55,4 +59,4 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder, ArgumentList>: Encode` + `ArgumentList, ArgumentList>: Encode` diff --git a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr index 1826315d23..f232190395 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr @@ -18,6 +18,9 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeEncode` is not satisfied note: required by a bound in `DispatchOutput` --> src/codegen/dispatch/type_check.rs | + | pub struct DispatchOutput(T) + | -------------- required by a bound in this struct + | where | T: scale::Encode + 'static; | ^^^^^^^^^^^^^ required by this bound in `DispatchOutput` @@ -28,9 +31,7 @@ error[E0599]: the method `try_invoke` exists for struct `CallBuilder