Add CheckNonZeroSender to runtime configs (#4493)

* Add CheckNonZeroSender to runtime configs

* cargo fmt

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes
This commit is contained in:
Keith Yeung
2021-12-12 02:22:08 -08:00
committed by GitHub
parent 0755ad39d3
commit 54423f8b8a
13 changed files with 27 additions and 4 deletions
@@ -532,6 +532,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
@@ -86,6 +86,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
@@ -549,6 +549,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
@@ -248,11 +248,12 @@ pub type UncheckedExtrinsic<Call> =
pub type Address = MultiAddress<AccountId, ()>;
/// A type of the data encoded as part of the transaction.
pub type SignedExtra = ((), (), (), sp_runtime::generic::Era, Compact<Nonce>, (), Compact<Balance>);
pub type SignedExtra =
((), (), (), (), sp_runtime::generic::Era, Compact<Nonce>, (), Compact<Balance>);
/// 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.
@@ -287,6 +288,7 @@ impl<Call> SignedExtensions<Call> {
) -> Self {
Self {
encode_payload: (
(), // non-zero sender
(), // spec version
(), // tx version
(), // genesis
@@ -296,6 +298,7 @@ impl<Call> SignedExtensions<Call> {
tip.into(), // transaction payment / tip (compact encoding)
),
additional_signed: (
(),
version.spec_version,
version.transaction_version,
genesis_hash,
@@ -312,12 +315,12 @@ impl<Call> SignedExtensions<Call> {
impl<Call> SignedExtensions<Call> {
/// 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()
}
}
@@ -78,6 +78,7 @@ impl ChainInfo for PolkadotChainInfo {
fn signed_extras(from: <Runtime as system::Config>::AccountId) -> Self::SignedExtras {
(
system::CheckNonZeroSender::<Runtime>::new(),
system::CheckSpecVersion::<Runtime>::new(),
system::CheckTxVersion::<Runtime>::new(),
system::CheckGenesis::<Runtime>::new(),
+2
View File
@@ -341,6 +341,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::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
@@ -353,6 +354,7 @@ pub fn construct_extrinsic(
function.clone(),
extra.clone(),
(
(),
VERSION.spec_version,
VERSION.transaction_version,
genesis_block,
+2
View File
@@ -869,6 +869,7 @@ where
.saturating_sub(1);
let tip = 0;
let extra: SignedExtra = (
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
@@ -1603,6 +1604,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
+2
View File
@@ -900,6 +900,7 @@ where
.saturating_sub(1);
let tip = 0;
let extra: SignedExtra = (
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
@@ -1552,6 +1553,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
@@ -438,6 +438,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(),
+2
View File
@@ -141,6 +141,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
@@ -354,6 +355,7 @@ where
.saturating_sub(1);
let tip = 0;
let extra: SignedExtra = (
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
+2
View File
@@ -385,6 +385,7 @@ where
let current_block = System::block_number().saturated_into::<u64>().saturating_sub(1);
let tip = 0;
let extra: SignedExtra = (
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
@@ -699,6 +700,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
+2
View File
@@ -573,6 +573,7 @@ where
.saturating_sub(1);
let tip = 0;
let extra: SignedExtra = (
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
@@ -1172,6 +1173,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
+3
View File
@@ -115,6 +115,7 @@ fn signed_ext_builder_polkadot(
) -> polkadot_runtime_exports::SignedExtra {
use polkadot_runtime_exports::Runtime;
(
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
@@ -133,6 +134,7 @@ fn signed_ext_builder_kusama(
) -> kusama_runtime_exports::SignedExtra {
use kusama_runtime_exports::Runtime;
(
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),
@@ -150,6 +152,7 @@ fn signed_ext_builder_westend(
) -> westend_runtime_exports::SignedExtra {
use westend_runtime_exports::Runtime;
(
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
frame_system::CheckGenesis::<Runtime>::new(),