From b032e6657989f75f727405f46292ff4ac2aa97c0 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 6 May 2020 07:43:29 +0100 Subject: [PATCH 1/6] Update to substrate alpha.7 --- Cargo.toml | 22 +++++++++++----------- proc-macro/Cargo.toml | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 43efe44e92..83f64ca449 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,20 +27,20 @@ serde_json = "1.0" url = "2.1" codec = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive", "full"] } -frame-metadata = { version = "11.0.0-alpha.6", package = "frame-metadata" } -frame-support = { version = "2.0.0-alpha.6", package = "frame-support" } -sp-runtime = { version = "2.0.0-alpha.6", package = "sp-runtime" } -sp-version = { version = "2.0.0-alpha.6", package = "sp-version" } -pallet-indices = { version = "2.0.0-alpha.6", package = "pallet-indices" } +frame-metadata = { version = "11.0.0-alpha.7", package = "frame-metadata" } +frame-support = { version = "2.0.0-alpha.7", package = "frame-support" } +sp-runtime = { version = "2.0.0-alpha.7", package = "sp-runtime" } +sp-version = { version = "2.0.0-alpha.7", package = "sp-version" } +pallet-indices = { version = "2.0.0-alpha.7", package = "pallet-indices" } hex = "0.4.0" -sp-rpc = { version = "2.0.0-alpha.6", package = "sp-rpc" } -sp-core = { version = "2.0.0-alpha.6", package = "sp-core" } -sp-transaction-pool = { version = "2.0.0-alpha.6", package = "sp-transaction-pool" } +sp-rpc = { version = "2.0.0-alpha.7", package = "sp-rpc" } +sp-core = { version = "2.0.0-alpha.7", package = "sp-core" } +sp-transaction-pool = { version = "2.0.0-alpha.7", package = "sp-transaction-pool" } [dev-dependencies] async-std = { version = "1.5.0", features = ["attributes"] } env_logger = "0.7" wabt = "0.9" -frame-system = { version = "2.0.0-alpha.6", package = "frame-system" } -pallet-balances = { version = "2.0.0-alpha.6", package = "pallet-balances" } -sp-keyring = { version = "2.0.0-alpha.6", package = "sp-keyring" } +frame-system = { version = "2.0.0-alpha.7", package = "frame-system" } +pallet-balances = { version = "2.0.0-alpha.7", package = "pallet-balances" } +sp-keyring = { version = "2.0.0-alpha.7", package = "sp-keyring" } diff --git a/proc-macro/Cargo.toml b/proc-macro/Cargo.toml index ccb78d3b84..54e2666672 100644 --- a/proc-macro/Cargo.toml +++ b/proc-macro/Cargo.toml @@ -20,11 +20,11 @@ synstructure = "0.12.3" async-std = { version = "1.5.0", features = ["attributes"] } codec = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive", "full"] } env_logger = "0.7.1" -frame-support = "2.0.0-alpha.6" +frame-support = "2.0.0-alpha.7" pretty_assertions = "0.6.1" -sp-core = "2.0.0-alpha.6" -sp-keyring = "2.0.0-alpha.6" -sp-runtime = "2.0.0-alpha.6" +sp-core = "2.0.0-alpha.7" +sp-keyring = "2.0.0-alpha.7" +sp-runtime = "2.0.0-alpha.7" substrate-subxt = { path = ".." } trybuild = "1.0.25" From b694888237b00c3886d3b7a91608afe34c921f71 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 6 May 2020 07:43:49 +0100 Subject: [PATCH 2/6] Remove gas limit from contracts put code --- src/frame/contracts.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/frame/contracts.rs b/src/frame/contracts.rs index e4cd4ee61d..b3abb7ec3d 100644 --- a/src/frame/contracts.rs +++ b/src/frame/contracts.rs @@ -41,9 +41,6 @@ pub trait Contracts: System + Balances {} /// You can instantiate contracts only with stored code. #[derive(Debug, Encode)] pub struct PutCodeCall<'a> { - /// Gas limit. - #[codec(compact)] - pub gas_limit: Gas, /// Wasm blob. pub code: &'a [u8], } @@ -174,7 +171,6 @@ mod tests { let result = xt .watch() .submit(PutCodeCall { - gas_limit: 500_000, code: &wasm, }) .await?; From b119f01dc51977c54969867f771ab67efb4e4987 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 6 May 2020 08:14:53 +0100 Subject: [PATCH 3/6] Rename SystemEvent::ReapedAccount to KilledAccount --- src/frame/system.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frame/system.rs b/src/frame/system.rs index ac3282931f..89ab461ab0 100644 --- a/src/frame/system.rs +++ b/src/frame/system.rs @@ -184,7 +184,7 @@ pub enum SystemEvent { /// A new account was created. NewAccount(T::AccountId), /// An account was reaped. - ReapedAccount(T::AccountId), + KilledAccount(T::AccountId), } /// A phase of a block's execution. From 13b44b8f39f8891ba9c84101d9cb96847a9a945b Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 6 May 2020 08:40:23 +0100 Subject: [PATCH 4/6] Log debug event received before attempting to decode --- src/events.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/events.rs b/src/events.rs index 991b66af5b..b1bb292ea8 100644 --- a/src/events.rs +++ b/src/events.rs @@ -225,6 +225,12 @@ impl EventsDecoder { let event_variant = input.read_byte()?; let event_metadata = module.event(event_variant)?; + log::debug!( + "received event '{}::{}'", + module.name(), + event_metadata.name + ); + let mut event_data = Vec::::new(); self.decode_raw_bytes( &event_metadata.arguments(), @@ -232,12 +238,7 @@ impl EventsDecoder { &mut event_data, )?; - log::debug!( - "received event '{}::{}', raw bytes: {}", - module.name(), - event_metadata.name, - hex::encode(&event_data), - ); + log::debug!("raw bytes: {}", hex::encode(&event_data),); RuntimeEvent::Raw(RawEvent { module: module.name().to_string(), From 8f9c2cd7f469943629e7a39741f7d6d4e46edf51 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 6 May 2020 08:41:08 +0100 Subject: [PATCH 5/6] Temporary registration of Balance type before #102 merged --- src/events.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/events.rs b/src/events.rs index b1bb292ea8..c2cfb10df0 100644 --- a/src/events.rs +++ b/src/events.rs @@ -95,6 +95,10 @@ impl TryFrom for EventsDecoder { type_sizes: HashMap::new(), marker: PhantomData, }; + // REMOVE when https://github.com/paritytech/substrate-subxt/pull/102 is merged + // Balance type will be registered by the proc macro. + decoder.register_type_size::("Balance")?; + // register default event arg type sizes for dynamic decoding of events decoder.register_type_size::("bool")?; decoder.register_type_size::("ReferendumIndex")?; From 7aea3850778f49cf82eb3d186848a665d2d7bf5a Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 6 May 2020 08:52:55 +0100 Subject: [PATCH 6/6] Show contract test errors, increase instantiate gas_limit --- src/frame/contracts.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/frame/contracts.rs b/src/frame/contracts.rs index b3abb7ec3d..820ee811de 100644 --- a/src/frame/contracts.rs +++ b/src/frame/contracts.rs @@ -168,12 +168,7 @@ mod tests { let xt = client.xt(signer, None).await?; - let result = xt - .watch() - .submit(PutCodeCall { - code: &wasm, - }) - .await?; + let result = xt.watch().submit(PutCodeCall { code: &wasm }).await?; let code_hash = result .find_event::>()? .ok_or(Error::Other("Failed to find CodeStored event".into()))? @@ -186,7 +181,7 @@ mod tests { #[ignore] // requires locally running substrate node fn tx_put_code() { env_logger::try_init().ok(); - let code_hash: Result<_, Error> = async_std::task::block_on(async move { + let code_hash_result: Result<_, Error> = async_std::task::block_on(async move { let signer = AccountKeyring::Alice.pair(); let client = test_client().await; let code_hash = put_code(&client, signer).await?; @@ -194,8 +189,11 @@ mod tests { }); assert!( - code_hash.is_ok(), - "Contracts CodeStored event should be received and decoded" + code_hash_result.is_ok(), + format!( + "Error calling put_code and receiving CodeStored Event: {:?}", + code_hash_result + ) ); } @@ -216,7 +214,7 @@ mod tests { .watch() .submit(InstantiateCall { endowment: 100_000_000_000_000, - gas_limit: 500_000, + gas_limit: 500_000_000, code_hash: &code_hash, data: &[], }) @@ -231,7 +229,7 @@ mod tests { assert!( result.is_ok(), - "Contract should be instantiated successfully" + format!("Error instantiating contract: {:?}", result) ); } }