From f35f0d258e51c9466c33a14b25b7598222faa43f Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 16 Dec 2022 13:29:58 -0500 Subject: [PATCH 1/8] Bump Substrate dependencies We also need to bump `subxt` to a version that uses the same versions of our Substrate deps. --- crates/e2e/Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index 397a2d098ee..ecfd258f5fa 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -30,14 +30,14 @@ tokio = { version = "1.18.2", features = ["rt-multi-thread"] } log = { version = "0.4" } env_logger = { version = "0.10" } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] } -subxt = "0.25.0" +subxt = { git = "https://github.com/paritytech/subxt", branch = "lexnv/update_sp_crates", package = "subxt" } # Substrate -pallet-contracts-primitives = "7.0.0" -sp-core = "7.0.0" -sp-keyring = "7.0.0" -sp-runtime = "7.0.0" -sp-weights = "4.0.0" +pallet-contracts-primitives = "9.0.0" +sp-core = "9.0.0" +sp-keyring = "9.0.0" +sp-runtime = "9.0.0" +sp-weights = "6.0.0" [dev-dependencies] # Required for the doctest of `MessageBuilder::call` From b0e05013720257e2331482b8e9f05319126e3ec6 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 16 Dec 2022 13:30:45 -0500 Subject: [PATCH 2/8] Use `Fundamental` trait directly Not sure why we're going through this hidden internal module --- crates/e2e/Cargo.toml | 1 + crates/e2e/src/client.rs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index ecfd258f5fa..2ae8aad138f 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -22,6 +22,7 @@ ink_env = { version = "4.0.0-beta", path = "../env" } ink_primitives = { version = "4.0.0-beta", path = "../primitives" } contract-metadata = { version = "2.0.0-beta.1" } +funty = "2.0.0" impl-serde = { version = "0.3.1", default-features = false } jsonrpsee = { version = "0.16.0", features = ["ws-client"] } serde = { version = "1.0.137", default-features = false, features = ["derive"] } diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index 6e7ed7f530b..4dfbb2e970c 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -51,7 +51,6 @@ use std::{ }; use subxt::{ blocks::ExtrinsicEvents, - ext::bitvec::macros::internal::funty::Fundamental, metadata::DecodeStaticType, storage::address::{ StorageHasher, @@ -472,6 +471,8 @@ where /// Generate a unique salt based on the system time. fn salt() -> Vec { + use funty::Fundamental as _; + std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .unwrap_or_else(|err| panic!("unable to get unix time: {}", err)) From 5f6b07e9d19df0f7bab3b09aa4121aa723059584 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Thu, 26 Jan 2023 16:16:39 -0800 Subject: [PATCH 3/8] Bump to `subxt@0.26` and accompanying Substrate deps --- crates/e2e/Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index 2ae8aad138f..b6671220b83 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -31,14 +31,14 @@ tokio = { version = "1.18.2", features = ["rt-multi-thread"] } log = { version = "0.4" } env_logger = { version = "0.10" } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] } -subxt = { git = "https://github.com/paritytech/subxt", branch = "lexnv/update_sp_crates", package = "subxt" } +subxt = { version = "0.26.0", features = ["substrate-compat"] } # Substrate -pallet-contracts-primitives = "9.0.0" -sp-core = "9.0.0" -sp-keyring = "9.0.0" -sp-runtime = "9.0.0" -sp-weights = "6.0.0" +pallet-contracts-primitives = "12.0.0" +sp-core = "11.0.0" +sp-keyring = "12.0.0" +sp-runtime = "12.0.0" +sp-weights = "8.0.0" [dev-dependencies] # Required for the doctest of `MessageBuilder::call` From b787e142455db08fc6b30f79df2d8adc6d5e7ba5 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Thu, 26 Jan 2023 17:23:55 -0800 Subject: [PATCH 4/8] Get E2E crate compiling again --- crates/e2e/src/client.rs | 25 +++++++++++++++++++------ crates/e2e/src/default_accounts.rs | 5 +++-- crates/e2e/src/lib.rs | 14 ++++++++------ crates/e2e/src/xts.rs | 18 +++++++++++------- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index 4dfbb2e970c..49df62eb6c5 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -49,15 +49,16 @@ use std::{ fmt::Debug, path::Path, }; + use subxt::{ blocks::ExtrinsicEvents, + config::ExtrinsicParams, metadata::DecodeStaticType, storage::address::{ StorageHasher, StorageMapKey, Yes, }, - tx::ExtrinsicParams, }; /// Result of a contract instantiation. @@ -105,6 +106,7 @@ where impl core::fmt::Debug for InstantiationResult where C: subxt::Config, + C::AccountId: Debug, E: Environment, ::AccountId: Debug, ::Balance: Debug, @@ -255,12 +257,13 @@ impl Client where C: subxt::Config, C::AccountId: Into + serde::de::DeserializeOwned, + C::AccountId: scale::Codec + Debug, C::Address: From, C::Signature: From, - ::Signer: From, + // ::Signer: From, >::OtherParams: Default, - ::Signer: - From + IdentifyAccount, + // ::Signer: + // From + IdentifyAccount, sr25519::Signature: Into, E: Environment, @@ -602,7 +605,12 @@ where let dry_run = self .api - .call_dry_run(signer.account_id().clone(), &message, value, None) + .call_dry_run( + subxt::tx::Signer::account_id(signer).clone(), + &message, + value, + None, + ) .await; log_info(&format!("call dry run: {:?}", &dry_run.result)); log_info(&format!( @@ -688,7 +696,12 @@ where .api .client .storage() - .fetch_or_default(&account_addr, None) + .at(None) + .await + .unwrap_or_else(|err| { + panic!("unable to fetch balance: {:?}", err); + }) + .fetch_or_default(&account_addr) .await .unwrap_or_else(|err| { panic!("unable to fetch balance: {:?}", err); diff --git a/crates/e2e/src/default_accounts.rs b/crates/e2e/src/default_accounts.rs index 1e0b542411a..c932d84f8fb 100644 --- a/crates/e2e/src/default_accounts.rs +++ b/crates/e2e/src/default_accounts.rs @@ -33,9 +33,10 @@ macro_rules! default_account { pub fn $fn_name() -> PairSigner where C: subxt::Config, - ::Signer: From, C::Signature: From, - ::Signer: IdentifyAccount, + C::AccountId: From + // ::Signer: From, + // ::Signer: IdentifyAccount, { PairSigner::new(AccountKeyring::$keyring_fn_name.pair()) } diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 7034c561066..640de0f3ae6 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -71,20 +71,22 @@ impl subxt::Config for SubstrateConfig { type Index = u32; type BlockNumber = u32; type Hash = sp_core::H256; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = sp_runtime::AccountId32; + type Hasher = subxt::config::substrate::BlakeTwo256; + type AccountId = subxt::config::substrate::AccountId32; type Address = sp_runtime::MultiAddress; - type Header = - sp_runtime::generic::Header; + type Header = subxt::config::substrate::SubstrateHeader< + Self::BlockNumber, + subxt::config::substrate::BlakeTwo256, + >; type Signature = sp_runtime::MultiSignature; - type ExtrinsicParams = subxt::tx::SubstrateExtrinsicParams; + type ExtrinsicParams = subxt::config::substrate::SubstrateExtrinsicParams; } /// Default set of commonly used types by Polkadot nodes. #[cfg(feature = "std")] pub type PolkadotConfig = subxt::config::WithExtrinsicParams< SubstrateConfig, - subxt::tx::PolkadotExtrinsicParams, + subxt::config::polkadot::PolkadotExtrinsicParams, >; /// Signer that is used throughout the E2E testing. diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index 36fccda7f57..880b87a8b39 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -41,7 +41,7 @@ use sp_core::{ use sp_weights::Weight; use subxt::{ blocks::ExtrinsicEvents, - tx::ExtrinsicParams, + config::ExtrinsicParams, OnlineClient, }; @@ -85,7 +85,10 @@ pub struct UploadCode { /// A struct that encodes RPC parameters required to instantiate a new smart contract. #[derive(serde::Serialize, scale::Encode)] #[serde(rename_all = "camelCase")] -struct RpcInstantiateRequest { +struct RpcInstantiateRequest +where + C::AccountId: scale::Codec, +{ origin: C::AccountId, value: E::Balance, gas_limit: Option, @@ -143,12 +146,13 @@ impl ContractsApi where C: subxt::Config, C::AccountId: Into + serde::de::DeserializeOwned, + C::AccountId: scale::Codec, >::OtherParams: Default, C::Signature: From, - ::Signer: From, - ::Signer: - From + IdentifyAccount, + // ::Signer: From, + // ::Signer: + // From + IdentifyAccount, sr25519::Signature: Into, E: Environment, @@ -186,7 +190,7 @@ where ) -> ContractInstantiateResult { let code = Code::Upload(code); let call_request = RpcInstantiateRequest:: { - origin: signer.account_id().clone(), + origin: subxt::tx::Signer::account_id(signer).clone(), value, gas_limit: None, storage_deposit_limit, @@ -275,7 +279,7 @@ where storage_deposit_limit: Option, ) -> CodeUploadResult { let call_request = RpcCodeUploadRequest:: { - origin: signer.account_id().clone(), + origin: subxt::tx::Signer::account_id(signer).clone(), code, storage_deposit_limit, }; From 3e9025140bf41c2b90d93020292c75b1274dd290 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Thu, 26 Jan 2023 17:29:06 -0800 Subject: [PATCH 5/8] Clean up trait bounds --- crates/e2e/src/client.rs | 11 +---------- crates/e2e/src/default_accounts.rs | 4 ---- crates/e2e/src/lib.rs | 4 ---- crates/e2e/src/xts.rs | 11 ++--------- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index 49df62eb6c5..22c79cbebd5 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -40,10 +40,6 @@ use super::{ use contract_metadata::ContractMetadata; use ink_env::Environment; -use sp_runtime::traits::{ - IdentifyAccount, - Verify, -}; use std::{ collections::BTreeMap, fmt::Debug, @@ -256,15 +252,10 @@ where impl Client where C: subxt::Config, - C::AccountId: Into + serde::de::DeserializeOwned, + C::AccountId: serde::de::DeserializeOwned, C::AccountId: scale::Codec + Debug, - C::Address: From, C::Signature: From, - // ::Signer: From, >::OtherParams: Default, - // ::Signer: - // From + IdentifyAccount, - sr25519::Signature: Into, E: Environment, E::AccountId: Debug, diff --git a/crates/e2e/src/default_accounts.rs b/crates/e2e/src/default_accounts.rs index c932d84f8fb..fe8349d8871 100644 --- a/crates/e2e/src/default_accounts.rs +++ b/crates/e2e/src/default_accounts.rs @@ -16,9 +16,7 @@ use super::{ AccountKeyring, - IdentifyAccount, PairSigner, - Verify, }; use sp_core::sr25519; @@ -35,8 +33,6 @@ macro_rules! default_account { C: subxt::Config, C::Signature: From, C::AccountId: From - // ::Signer: From, - // ::Signer: IdentifyAccount, { PairSigner::new(AccountKeyring::$keyring_fn_name.pair()) } diff --git a/crates/e2e/src/lib.rs b/crates/e2e/src/lib.rs index 640de0f3ae6..f52850e84bf 100644 --- a/crates/e2e/src/lib.rs +++ b/crates/e2e/src/lib.rs @@ -52,10 +52,6 @@ use pallet_contracts_primitives::{ ContractInstantiateResult, }; use sp_core::sr25519; -use sp_runtime::traits::{ - IdentifyAccount, - Verify, -}; use std::{ cell::RefCell, sync::Once, diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index 880b87a8b39..1d6f2d3e4e3 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -18,9 +18,7 @@ use super::{ sr25519, ContractExecResult, ContractInstantiateResult, - IdentifyAccount, Signer, - Verify, }; use ink_env::Environment; @@ -145,15 +143,10 @@ pub struct ContractsApi { impl ContractsApi where C: subxt::Config, - C::AccountId: Into + serde::de::DeserializeOwned, + C::AccountId: serde::de::DeserializeOwned, C::AccountId: scale::Codec, - >::OtherParams: Default, - C::Signature: From, - // ::Signer: From, - // ::Signer: - // From + IdentifyAccount, - sr25519::Signature: Into, + >::OtherParams: Default, E: Environment, E::Balance: scale::Encode + serde::Serialize, From e01295c69a7969f1f7b217a60ceac6636d8996ab Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Thu, 26 Jan 2023 18:00:08 -0800 Subject: [PATCH 6/8] Clean up signer generation --- crates/e2e/src/client.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/crates/e2e/src/client.rs b/crates/e2e/src/client.rs index dbbb7873e57..903269a2c75 100644 --- a/crates/e2e/src/client.rs +++ b/crates/e2e/src/client.rs @@ -47,16 +47,7 @@ use subxt::{ Value, ValueDef, }, - metadata::DecodeStaticType, - storage::address::{ - StorageHasher, - StorageMapKey, - Yes, - }, - tx::{ - PairSigner, - Signer as _, - }, + tx::PairSigner, }; /// Result of a contract instantiation. @@ -352,11 +343,8 @@ where C::AccountId: From, { let (pair, _, _) = ::generate_with_phrase(None); - // let account_id = - // ::Signer::from(pair.public()).into_account(); - - let account_id: C::AccountId = - PairSigner::::new(pair.clone()).account_id().clone(); + let pair_signer = PairSigner::::new(pair); + let account_id = pair_signer.account_id().to_owned(); for _ in 0..6 { let transfer_result = self @@ -384,7 +372,7 @@ where } } - PairSigner::new(pair) + pair_signer } /// This function extracts the metadata of the contract at the file path From 376401c94fdfe9f6c047822e49421fde9970b587 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Thu, 26 Jan 2023 18:06:17 -0800 Subject: [PATCH 7/8] Remove default feature --- crates/e2e/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/e2e/Cargo.toml b/crates/e2e/Cargo.toml index e9c5a808e72..3705bf9cd28 100644 --- a/crates/e2e/Cargo.toml +++ b/crates/e2e/Cargo.toml @@ -30,7 +30,7 @@ tokio = { version = "1.18.2", features = ["rt-multi-thread"] } log = { version = "0.4" } env_logger = { version = "0.10" } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] } -subxt = { version = "0.26.0", features = ["substrate-compat"] } +subxt = "0.26.0" # Substrate pallet-contracts-primitives = "12.0.0" From 9e44a14f758c965d68d3c85036f44e1658792b7c Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 27 Jan 2023 09:51:36 +0000 Subject: [PATCH 8/8] Remove bound on struct --- crates/e2e/src/xts.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/e2e/src/xts.rs b/crates/e2e/src/xts.rs index 7814175e2ba..a5d94d30eba 100644 --- a/crates/e2e/src/xts.rs +++ b/crates/e2e/src/xts.rs @@ -116,10 +116,7 @@ pub struct UploadCode { /// A struct that encodes RPC parameters required to instantiate a new smart contract. #[derive(serde::Serialize, scale::Encode)] #[serde(rename_all = "camelCase")] -struct RpcInstantiateRequest -where - C::AccountId: scale::Codec, -{ +struct RpcInstantiateRequest { origin: C::AccountId, value: E::Balance, gas_limit: Option,