From ce066cf8f45da8a51b5c3c0ab504a5e1d1f0156c Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 8 Dec 2021 12:27:13 -0800 Subject: [PATCH 1/7] Add CheckNonZeroSender to runtime configs --- bridges/bin/millau/runtime/src/lib.rs | 1 + bridges/bin/rialto-parachain/runtime/src/lib.rs | 1 + bridges/bin/rialto/runtime/src/lib.rs | 1 + bridges/primitives/polkadot-core/src/lib.rs | 2 +- node/test/service/src/lib.rs | 1 + runtime/kusama/src/lib.rs | 2 ++ runtime/polkadot/src/lib.rs | 2 ++ runtime/rococo/src/bridge_messages.rs | 1 + runtime/rococo/src/lib.rs | 2 ++ runtime/test-runtime/src/lib.rs | 2 ++ runtime/westend/src/lib.rs | 2 ++ 11 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bridges/bin/millau/runtime/src/lib.rs b/bridges/bin/millau/runtime/src/lib.rs index d230e7aadd8e..5f59046780ed 100644 --- a/bridges/bin/millau/runtime/src/lib.rs +++ b/bridges/bin/millau/runtime/src/lib.rs @@ -531,6 +531,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The `SignedExtension` to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, diff --git a/bridges/bin/rialto-parachain/runtime/src/lib.rs b/bridges/bin/rialto-parachain/runtime/src/lib.rs index 5b71674b7fe9..e4ac28d2ad7b 100644 --- a/bridges/bin/rialto-parachain/runtime/src/lib.rs +++ b/bridges/bin/rialto-parachain/runtime/src/lib.rs @@ -86,6 +86,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckGenesis, frame_system::CheckEra, diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 6a4cb90a4fde..f88db92940b4 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -548,6 +548,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The `SignedExtension` to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index 38e43d312b5d..d345412f87cc 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -248,7 +248,7 @@ pub type UncheckedExtrinsic = pub type Address = MultiAddress; /// A type of the data encoded as part of the transaction. -pub type SignedExtra = ((), (), (), sp_runtime::generic::Era, Compact, (), Compact); +pub type SignedExtra = ((), (), (), (), sp_runtime::generic::Era, Compact, (), Compact); /// Parameters which are part of the payload used to produce transaction signature, /// but don't end up in the transaction itself (i.e. inherent part of the runtime). diff --git a/node/test/service/src/lib.rs b/node/test/service/src/lib.rs index 103be52c5fd7..5a2f654aaa5b 100644 --- a/node/test/service/src/lib.rs +++ b/node/test/service/src/lib.rs @@ -340,6 +340,7 @@ pub fn construct_extrinsic( BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64; let tip = 0; let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index d3685309ed48..a88bb0979bd4 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -852,6 +852,7 @@ where .saturating_sub(1); let tip = 0; let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -1582,6 +1583,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The `SignedExtension` to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index fedceb31fbb2..cfad1a0f28dc 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -882,6 +882,7 @@ where .saturating_sub(1); let tip = 0; let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -1532,6 +1533,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The `SignedExtension` to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, diff --git a/runtime/rococo/src/bridge_messages.rs b/runtime/rococo/src/bridge_messages.rs index 31568f5c51bc..d800910d403d 100644 --- a/runtime/rococo/src/bridge_messages.rs +++ b/runtime/rococo/src/bridge_messages.rs @@ -436,6 +436,7 @@ mod tests { // file if you're unsure who to ping) let signed_extra: crate::SignedExtra = ( + frame_system::CheckNonZeroSender::new(), frame_system::CheckSpecVersion::new(), frame_system::CheckTxVersion::new(), frame_system::CheckGenesis::new(), diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 8e4d75ec34b7..2b0cb718fe81 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -141,6 +141,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The `SignedExtension` to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, @@ -353,6 +354,7 @@ where .saturating_sub(1); let tip = 0; let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 7c20da6d9e19..7eddca6babe1 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -385,6 +385,7 @@ where let current_block = System::block_number().saturated_into::().saturating_sub(1); let tip = 0; let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -699,6 +700,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The `SignedExtension` to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 1d9b9a25a1ae..1ae1446d94aa 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -556,6 +556,7 @@ where .saturating_sub(1); let tip = 0; let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -1152,6 +1153,7 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The `SignedExtension` to the basic transaction logic. pub type SignedExtra = ( + frame_system::CheckNonZeroSender, frame_system::CheckSpecVersion, frame_system::CheckTxVersion, frame_system::CheckGenesis, From e5b5e05b6692d1ea322aa1e9bd818f6b604e7ae2 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 8 Dec 2021 12:30:16 -0800 Subject: [PATCH 2/7] cargo fmt --- bridges/primitives/polkadot-core/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index d345412f87cc..29033d5527d5 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -248,7 +248,8 @@ pub type UncheckedExtrinsic = pub type Address = MultiAddress; /// A type of the data encoded as part of the transaction. -pub type SignedExtra = ((), (), (), (), sp_runtime::generic::Era, Compact, (), Compact); +pub type SignedExtra = + ((), (), (), (), sp_runtime::generic::Era, Compact, (), Compact); /// Parameters which are part of the payload used to produce transaction signature, /// but don't end up in the transaction itself (i.e. inherent part of the runtime). From c33842c8d765fd5860e2743ef89ee0894620d5ab Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 8 Dec 2021 18:01:43 -0800 Subject: [PATCH 3/7] Fixes --- bridges/primitives/polkadot-core/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index 29033d5527d5..23a8fa15b7a0 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -288,6 +288,7 @@ impl SignedExtensions { ) -> Self { Self { encode_payload: ( + (), // non-zero sender (), // spec version (), // tx version (), // genesis @@ -297,6 +298,7 @@ impl SignedExtensions { tip.into(), // transaction payment / tip (compact encoding) ), additional_signed: ( + (), version.spec_version, version.transaction_version, genesis_hash, @@ -313,12 +315,12 @@ impl SignedExtensions { impl SignedExtensions { /// Return signer nonce, used to craft transaction. pub fn nonce(&self) -> Nonce { - self.encode_payload.4.into() + self.encode_payload.5.into() } /// Return transaction tip. pub fn tip(&self) -> Balance { - self.encode_payload.6.into() + self.encode_payload.7.into() } } From cc174a70407aa285032480de12da3f3bd95b22a6 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 8 Dec 2021 18:28:24 -0800 Subject: [PATCH 4/7] Fixes --- bridges/primitives/polkadot-core/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs index 23a8fa15b7a0..68fd879590a9 100644 --- a/bridges/primitives/polkadot-core/src/lib.rs +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -253,7 +253,7 @@ pub type SignedExtra = /// Parameters which are part of the payload used to produce transaction signature, /// but don't end up in the transaction itself (i.e. inherent part of the runtime). -pub type AdditionalSigned = (u32, u32, Hash, Hash, (), (), ()); +pub type AdditionalSigned = ((), u32, u32, Hash, Hash, (), (), ()); /// A simplified version of signed extensions meant for producing signed transactions /// and signed payload in the client code. From d2a25350f7c4063d41f96c87a9dff90780dfed73 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 8 Dec 2021 19:35:15 -0800 Subject: [PATCH 5/7] Fixes --- utils/staking-miner/src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/staking-miner/src/main.rs b/utils/staking-miner/src/main.rs index 95319f9e24a4..f05897b426b0 100644 --- a/utils/staking-miner/src/main.rs +++ b/utils/staking-miner/src/main.rs @@ -115,6 +115,7 @@ fn signed_ext_builder_polkadot( ) -> polkadot_runtime_exports::SignedExtra { use polkadot_runtime_exports::Runtime; ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -133,6 +134,7 @@ fn signed_ext_builder_kusama( ) -> kusama_runtime_exports::SignedExtra { use kusama_runtime_exports::Runtime; ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), @@ -150,6 +152,7 @@ fn signed_ext_builder_westend( ) -> westend_runtime_exports::SignedExtra { use westend_runtime_exports::Runtime; ( + frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), frame_system::CheckTxVersion::::new(), frame_system::CheckGenesis::::new(), From 42bbcf9f8874f18ffaec436c555aeec03e280b7e Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 8 Dec 2021 21:23:41 -0800 Subject: [PATCH 6/7] Fixes --- node/test/service/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/test/service/src/lib.rs b/node/test/service/src/lib.rs index 5a2f654aaa5b..8ebbd5b0edc3 100644 --- a/node/test/service/src/lib.rs +++ b/node/test/service/src/lib.rs @@ -353,6 +353,7 @@ pub fn construct_extrinsic( function.clone(), extra.clone(), ( + (), VERSION.spec_version, VERSION.transaction_version, genesis_block, From 16b7cd388a2ef7d7a9589b9d1e3f6ce5d063868f Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Wed, 8 Dec 2021 21:40:42 -0800 Subject: [PATCH 7/7] Fixes --- node/test/polkadot-simnet/common/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node/test/polkadot-simnet/common/src/lib.rs b/node/test/polkadot-simnet/common/src/lib.rs index 47047ec202ce..668417e10b99 100644 --- a/node/test/polkadot-simnet/common/src/lib.rs +++ b/node/test/polkadot-simnet/common/src/lib.rs @@ -78,6 +78,7 @@ impl ChainInfo for PolkadotChainInfo { fn signed_extras(from: ::AccountId) -> Self::SignedExtras { ( + system::CheckNonZeroSender::::new(), system::CheckSpecVersion::::new(), system::CheckTxVersion::::new(), system::CheckGenesis::::new(),