mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 04:11:07 +00:00
This PR reverts #2280 which introduced `TransactionExtension` to replace `SignedExtension`. As a result of the discussion [here](https://github.com/paritytech/polkadot-sdk/pull/3623#issuecomment-1986789700), the changes will be reverted for now with plans to reintroduce the concept in the future. --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
This commit is contained in:
@@ -196,7 +196,6 @@ runtime-benchmarks = [
|
||||
"frame-system/runtime-benchmarks",
|
||||
"kitchensink-runtime/runtime-benchmarks",
|
||||
"node-inspect?/runtime-benchmarks",
|
||||
"pallet-asset-conversion-tx-payment/runtime-benchmarks",
|
||||
"pallet-asset-tx-payment/runtime-benchmarks",
|
||||
"pallet-assets/runtime-benchmarks",
|
||||
"pallet-balances/runtime-benchmarks",
|
||||
@@ -206,7 +205,6 @@ runtime-benchmarks = [
|
||||
"pallet-skip-feeless-payment/runtime-benchmarks",
|
||||
"pallet-sudo/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"pallet-transaction-payment/runtime-benchmarks",
|
||||
"pallet-treasury/runtime-benchmarks",
|
||||
"sc-client-db/runtime-benchmarks",
|
||||
"sc-service/runtime-benchmarks",
|
||||
|
||||
@@ -110,7 +110,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
|
||||
|
||||
fn extrinsic_set_time(now: u64) -> OpaqueExtrinsic {
|
||||
kitchensink_runtime::UncheckedExtrinsic {
|
||||
preamble: sp_runtime::generic::Preamble::Bare,
|
||||
signature: None,
|
||||
function: kitchensink_runtime::RuntimeCall::Timestamp(pallet_timestamp::Call::set { now }),
|
||||
}
|
||||
.into()
|
||||
|
||||
@@ -29,7 +29,7 @@ use sp_core::{
|
||||
storage::well_known_keys,
|
||||
traits::{CallContext, CodeExecutor, RuntimeCode},
|
||||
};
|
||||
use sp_runtime::{generic::ExtrinsicFormat, traits::BlakeTwo256};
|
||||
use sp_runtime::traits::BlakeTwo256;
|
||||
use sp_state_machine::TestExternalities as CoreTestExternalities;
|
||||
use staging_node_cli::service::RuntimeExecutor;
|
||||
|
||||
@@ -144,11 +144,11 @@ fn test_blocks(
|
||||
) -> Vec<(Vec<u8>, Hash)> {
|
||||
let mut test_ext = new_test_ext(genesis_config);
|
||||
let mut block1_extrinsics = vec![CheckedExtrinsic {
|
||||
format: ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: 0 }),
|
||||
}];
|
||||
block1_extrinsics.extend((0..20).map(|i| CheckedExtrinsic {
|
||||
format: ExtrinsicFormat::Signed(alice(), tx_ext(i, 0)),
|
||||
signed: Some((alice(), signed_extra(i, 0))),
|
||||
function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
|
||||
dest: bob().into(),
|
||||
value: 1 * DOLLARS,
|
||||
|
||||
@@ -107,21 +107,18 @@ pub fn create_extrinsic(
|
||||
.map(|c| c / 2)
|
||||
.unwrap_or(2) as u64;
|
||||
let tip = 0;
|
||||
let tx_ext: kitchensink_runtime::TxExtension =
|
||||
let extra: kitchensink_runtime::SignedExtra =
|
||||
(
|
||||
(
|
||||
frame_system::CheckNonZeroSender::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckGenesis::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckEra::<kitchensink_runtime::Runtime>::from(generic::Era::mortal(
|
||||
period,
|
||||
best_block.saturated_into(),
|
||||
)),
|
||||
frame_system::CheckNonce::<kitchensink_runtime::Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<kitchensink_runtime::Runtime>::new(),
|
||||
)
|
||||
.into(),
|
||||
frame_system::CheckNonZeroSender::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckGenesis::<kitchensink_runtime::Runtime>::new(),
|
||||
frame_system::CheckEra::<kitchensink_runtime::Runtime>::from(generic::Era::mortal(
|
||||
period,
|
||||
best_block.saturated_into(),
|
||||
)),
|
||||
frame_system::CheckNonce::<kitchensink_runtime::Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<kitchensink_runtime::Runtime>::new(),
|
||||
pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
|
||||
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<
|
||||
kitchensink_runtime::Runtime,
|
||||
@@ -131,17 +128,15 @@ pub fn create_extrinsic(
|
||||
|
||||
let raw_payload = kitchensink_runtime::SignedPayload::from_raw(
|
||||
function.clone(),
|
||||
tx_ext.clone(),
|
||||
extra.clone(),
|
||||
(
|
||||
(
|
||||
(),
|
||||
kitchensink_runtime::VERSION.spec_version,
|
||||
kitchensink_runtime::VERSION.transaction_version,
|
||||
genesis_hash,
|
||||
best_hash,
|
||||
(),
|
||||
(),
|
||||
),
|
||||
(),
|
||||
kitchensink_runtime::VERSION.spec_version,
|
||||
kitchensink_runtime::VERSION.transaction_version,
|
||||
genesis_hash,
|
||||
best_hash,
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
),
|
||||
);
|
||||
@@ -151,7 +146,7 @@ pub fn create_extrinsic(
|
||||
function,
|
||||
sp_runtime::AccountId32::from(sender.public()).into(),
|
||||
kitchensink_runtime::Signature::Sr25519(signature),
|
||||
tx_ext,
|
||||
extra,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -796,7 +791,7 @@ mod tests {
|
||||
use codec::Encode;
|
||||
use kitchensink_runtime::{
|
||||
constants::{currency::CENTS, time::SLOT_DURATION},
|
||||
Address, BalancesCall, RuntimeCall, TxExtension, UncheckedExtrinsic,
|
||||
Address, BalancesCall, RuntimeCall, UncheckedExtrinsic,
|
||||
};
|
||||
use node_primitives::{Block, DigestItem, Signature};
|
||||
use sc_client_api::BlockBackend;
|
||||
@@ -998,31 +993,25 @@ mod tests {
|
||||
let tx_payment = pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
|
||||
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::from(0, None),
|
||||
);
|
||||
let tx_ext: TxExtension = (
|
||||
(
|
||||
check_non_zero_sender,
|
||||
check_spec_version,
|
||||
check_tx_version,
|
||||
check_genesis,
|
||||
check_era,
|
||||
check_nonce,
|
||||
check_weight,
|
||||
)
|
||||
.into(),
|
||||
let extra = (
|
||||
check_non_zero_sender,
|
||||
check_spec_version,
|
||||
check_tx_version,
|
||||
check_genesis,
|
||||
check_era,
|
||||
check_nonce,
|
||||
check_weight,
|
||||
tx_payment,
|
||||
);
|
||||
let raw_payload = SignedPayload::from_raw(
|
||||
function,
|
||||
tx_ext,
|
||||
(
|
||||
((), spec_version, transaction_version, genesis_hash, genesis_hash, (), ()),
|
||||
(),
|
||||
),
|
||||
extra,
|
||||
((), spec_version, transaction_version, genesis_hash, genesis_hash, (), (), ()),
|
||||
);
|
||||
let signature = raw_payload.using_encoded(|payload| signer.sign(payload));
|
||||
let (function, tx_ext, _) = raw_payload.deconstruct();
|
||||
let (function, extra, _) = raw_payload.deconstruct();
|
||||
index += 1;
|
||||
UncheckedExtrinsic::new_signed(function, from.into(), signature.into(), tx_ext)
|
||||
UncheckedExtrinsic::new_signed(function, from.into(), signature.into(), extra)
|
||||
.into()
|
||||
},
|
||||
);
|
||||
|
||||
@@ -67,7 +67,7 @@ fn transfer_fee<E: Encode>(extrinsic: &E) -> Balance {
|
||||
|
||||
fn xt() -> UncheckedExtrinsic {
|
||||
sign(CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(alice(), tx_ext(0, 0)),
|
||||
signed: Some((alice(), signed_extra(0, 0))),
|
||||
function: RuntimeCall::Balances(default_transfer_call()),
|
||||
})
|
||||
}
|
||||
@@ -84,11 +84,11 @@ fn changes_trie_block() -> (Vec<u8>, Hash) {
|
||||
GENESIS_HASH.into(),
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time }),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(alice(), tx_ext(0, 0)),
|
||||
signed: Some((alice(), signed_extra(0, 0))),
|
||||
function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
|
||||
dest: bob().into(),
|
||||
value: 69 * DOLLARS,
|
||||
@@ -111,11 +111,11 @@ fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
|
||||
GENESIS_HASH.into(),
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time1 }),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(alice(), tx_ext(0, 0)),
|
||||
signed: Some((alice(), signed_extra(0, 0))),
|
||||
function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
|
||||
dest: bob().into(),
|
||||
value: 69 * DOLLARS,
|
||||
@@ -131,18 +131,18 @@ fn blocks() -> ((Vec<u8>, Hash), (Vec<u8>, Hash)) {
|
||||
block1.1,
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time2 }),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(bob(), tx_ext(0, 0)),
|
||||
signed: Some((bob(), signed_extra(0, 0))),
|
||||
function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
|
||||
dest: alice().into(),
|
||||
value: 5 * DOLLARS,
|
||||
}),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(alice(), tx_ext(1, 0)),
|
||||
signed: Some((alice(), signed_extra(1, 0))),
|
||||
function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
|
||||
dest: bob().into(),
|
||||
value: 15 * DOLLARS,
|
||||
@@ -166,11 +166,11 @@ fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
|
||||
GENESIS_HASH.into(),
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(alice(), tx_ext(nonce, 0)),
|
||||
signed: Some((alice(), signed_extra(nonce, 0))),
|
||||
function: RuntimeCall::System(frame_system::Call::remark { remark: vec![0; size] }),
|
||||
},
|
||||
],
|
||||
@@ -677,11 +677,11 @@ fn deploying_wasm_contract_should_work() {
|
||||
GENESIS_HASH.into(),
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time }),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(charlie(), tx_ext(0, 0)),
|
||||
signed: Some((charlie(), signed_extra(0, 0))),
|
||||
function: RuntimeCall::Contracts(pallet_contracts::Call::instantiate_with_code::<
|
||||
Runtime,
|
||||
> {
|
||||
@@ -694,7 +694,7 @@ fn deploying_wasm_contract_should_work() {
|
||||
}),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(charlie(), tx_ext(1, 0)),
|
||||
signed: Some((charlie(), signed_extra(1, 0))),
|
||||
function: RuntimeCall::Contracts(pallet_contracts::Call::call::<Runtime> {
|
||||
dest: sp_runtime::MultiAddress::Id(addr.clone()),
|
||||
value: 10,
|
||||
|
||||
@@ -54,11 +54,11 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
|
||||
GENESIS_HASH.into(),
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time1 }),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(charlie(), tx_ext(0, 0)),
|
||||
signed: Some((charlie(), signed_extra(0, 0))),
|
||||
function: RuntimeCall::Sudo(pallet_sudo::Call::sudo {
|
||||
call: Box::new(RuntimeCall::RootTesting(
|
||||
pallet_root_testing::Call::fill_block { ratio: Perbill::from_percent(60) },
|
||||
@@ -77,11 +77,11 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
|
||||
block1.1,
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time2 }),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(charlie(), tx_ext(1, 0)),
|
||||
signed: Some((charlie(), signed_extra(1, 0))),
|
||||
function: RuntimeCall::System(frame_system::Call::remark { remark: vec![0; 1] }),
|
||||
},
|
||||
],
|
||||
@@ -147,7 +147,7 @@ fn transaction_fee_is_correct() {
|
||||
|
||||
let tip = 1_000_000;
|
||||
let xt = sign(CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(alice(), tx_ext(0, tip)),
|
||||
signed: Some((alice(), signed_extra(0, tip))),
|
||||
function: RuntimeCall::Balances(default_transfer_call()),
|
||||
});
|
||||
|
||||
@@ -211,10 +211,7 @@ fn block_weight_capacity_report() {
|
||||
let num_transfers = block_number * factor;
|
||||
let mut xts = (0..num_transfers)
|
||||
.map(|i| CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(
|
||||
charlie(),
|
||||
tx_ext(nonce + i as Nonce, 0),
|
||||
),
|
||||
signed: Some((charlie(), signed_extra(nonce + i as Nonce, 0))),
|
||||
function: RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
|
||||
dest: bob().into(),
|
||||
value: 0,
|
||||
@@ -225,7 +222,7 @@ fn block_weight_capacity_report() {
|
||||
xts.insert(
|
||||
0,
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }),
|
||||
},
|
||||
);
|
||||
@@ -288,16 +285,13 @@ fn block_length_capacity_report() {
|
||||
previous_hash,
|
||||
vec![
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Bare,
|
||||
signed: None,
|
||||
function: RuntimeCall::Timestamp(pallet_timestamp::Call::set {
|
||||
now: time * 1000,
|
||||
}),
|
||||
},
|
||||
CheckedExtrinsic {
|
||||
format: sp_runtime::generic::ExtrinsicFormat::Signed(
|
||||
charlie(),
|
||||
tx_ext(nonce, 0),
|
||||
),
|
||||
signed: Some((charlie(), signed_extra(nonce, 0))),
|
||||
function: RuntimeCall::System(frame_system::Call::remark {
|
||||
remark: vec![0u8; (block_number * factor) as usize],
|
||||
}),
|
||||
|
||||
@@ -130,8 +130,8 @@ fn should_submit_signed_twice_from_the_same_account() {
|
||||
// now check that the transaction nonces are not equal
|
||||
let s = state.read();
|
||||
fn nonce(tx: UncheckedExtrinsic) -> frame_system::CheckNonce<Runtime> {
|
||||
let extra = tx.preamble.to_signed().unwrap().2;
|
||||
(extra.0).5
|
||||
let extra = tx.signature.unwrap().2;
|
||||
extra.5
|
||||
}
|
||||
let nonce1 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[0]).unwrap());
|
||||
let nonce2 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[1]).unwrap());
|
||||
@@ -179,8 +179,8 @@ fn should_submit_signed_twice_from_all_accounts() {
|
||||
// now check that the transaction nonces are not equal
|
||||
let s = state.read();
|
||||
fn nonce(tx: UncheckedExtrinsic) -> frame_system::CheckNonce<Runtime> {
|
||||
let extra = tx.preamble.to_signed().unwrap().2;
|
||||
(extra.0).5
|
||||
let extra = tx.signature.unwrap().2;
|
||||
extra.5
|
||||
}
|
||||
let nonce1 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[0]).unwrap());
|
||||
let nonce2 = nonce(UncheckedExtrinsic::decode(&mut &*s.transactions[1]).unwrap());
|
||||
@@ -236,7 +236,7 @@ fn submitted_transaction_should_be_valid() {
|
||||
let source = TransactionSource::External;
|
||||
let extrinsic = UncheckedExtrinsic::decode(&mut &*tx0).unwrap();
|
||||
// add balance to the account
|
||||
let author = extrinsic.preamble.clone().to_signed().clone().unwrap().0;
|
||||
let author = extrinsic.signature.clone().unwrap().0;
|
||||
let address = Indices::lookup(author).unwrap();
|
||||
let data = pallet_balances::AccountData { free: 5_000_000_000_000, ..Default::default() };
|
||||
let account = frame_system::AccountInfo { providers: 1, data, ..Default::default() };
|
||||
|
||||
@@ -276,7 +276,6 @@ runtime-benchmarks = [
|
||||
"frame-system-benchmarking/runtime-benchmarks",
|
||||
"frame-system/runtime-benchmarks",
|
||||
"pallet-alliance/runtime-benchmarks",
|
||||
"pallet-asset-conversion-tx-payment/runtime-benchmarks",
|
||||
"pallet-asset-conversion/runtime-benchmarks",
|
||||
"pallet-asset-rate/runtime-benchmarks",
|
||||
"pallet-asset-tx-payment/runtime-benchmarks",
|
||||
@@ -334,7 +333,6 @@ runtime-benchmarks = [
|
||||
"pallet-sudo/runtime-benchmarks",
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"pallet-tips/runtime-benchmarks",
|
||||
"pallet-transaction-payment/runtime-benchmarks",
|
||||
"pallet-transaction-storage/runtime-benchmarks",
|
||||
"pallet-treasury/runtime-benchmarks",
|
||||
"pallet-tx-pause/runtime-benchmarks",
|
||||
|
||||
@@ -560,7 +560,6 @@ impl pallet_transaction_payment::Config for Runtime {
|
||||
MinimumMultiplier,
|
||||
MaximumMultiplier,
|
||||
>;
|
||||
type WeightInfo = pallet_transaction_payment::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_asset_tx_payment::Config for Runtime {
|
||||
@@ -570,9 +569,6 @@ impl pallet_asset_tx_payment::Config for Runtime {
|
||||
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto, Instance1>,
|
||||
CreditToBlockAuthor,
|
||||
>;
|
||||
type WeightInfo = pallet_asset_tx_payment::weights::SubstrateWeight<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = AssetTxHelper;
|
||||
}
|
||||
|
||||
impl pallet_asset_conversion_tx_payment::Config for Runtime {
|
||||
@@ -583,9 +579,6 @@ impl pallet_asset_conversion_tx_payment::Config for Runtime {
|
||||
AssetConversion,
|
||||
Native,
|
||||
>;
|
||||
type WeightInfo = pallet_asset_conversion_tx_payment::weights::SubstrateWeight<Runtime>;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = AssetConversionTxHelper;
|
||||
}
|
||||
|
||||
impl pallet_skip_feeless_payment::Config for Runtime {
|
||||
@@ -1416,33 +1409,29 @@ where
|
||||
// so the actual block number is `n`.
|
||||
.saturating_sub(1);
|
||||
let era = Era::mortal(period, current_block);
|
||||
let tx_ext: TxExtension = (
|
||||
(
|
||||
frame_system::CheckNonZeroSender::<Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<Runtime>::new(),
|
||||
frame_system::CheckGenesis::<Runtime>::new(),
|
||||
frame_system::CheckEra::<Runtime>::from(era),
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
)
|
||||
.into(),
|
||||
let extra = (
|
||||
frame_system::CheckNonZeroSender::<Runtime>::new(),
|
||||
frame_system::CheckSpecVersion::<Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<Runtime>::new(),
|
||||
frame_system::CheckGenesis::<Runtime>::new(),
|
||||
frame_system::CheckEra::<Runtime>::from(era),
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
|
||||
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::<Runtime>::from(
|
||||
tip, None,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
let raw_payload = SignedPayload::new(call, tx_ext)
|
||||
let raw_payload = SignedPayload::new(call, extra)
|
||||
.map_err(|e| {
|
||||
log::warn!("Unable to create signed payload: {:?}", e);
|
||||
})
|
||||
.ok()?;
|
||||
let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
|
||||
let address = Indices::unlookup(account);
|
||||
let (call, tx_ext, _) = raw_payload.deconstruct();
|
||||
Some((call, (address, signature, tx_ext)))
|
||||
let (call, extra, _) = raw_payload.deconstruct();
|
||||
Some((call, (address, signature, extra)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2461,21 +2450,19 @@ pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type SignedBlock = generic::SignedBlock<Block>;
|
||||
/// BlockId type as expected by this runtime.
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// The TransactionExtension to the basic transaction logic.
|
||||
/// The SignedExtension to the basic transaction logic.
|
||||
///
|
||||
/// When you change this, you **MUST** modify [`sign`] in `bin/node/testing/src/keyring.rs`!
|
||||
///
|
||||
/// [`sign`]: <../../testing/src/keyring.rs.html>
|
||||
pub type TxExtension = (
|
||||
(
|
||||
frame_system::CheckNonZeroSender<Runtime>,
|
||||
frame_system::CheckSpecVersion<Runtime>,
|
||||
frame_system::CheckTxVersion<Runtime>,
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
),
|
||||
pub type SignedExtra = (
|
||||
frame_system::CheckNonZeroSender<Runtime>,
|
||||
frame_system::CheckSpecVersion<Runtime>,
|
||||
frame_system::CheckTxVersion<Runtime>,
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_skip_feeless_payment::SkipCheckIfFeeless<
|
||||
Runtime,
|
||||
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment<Runtime>,
|
||||
@@ -2484,11 +2471,11 @@ pub type TxExtension = (
|
||||
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic =
|
||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, TxExtension>;
|
||||
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
|
||||
/// The payload being signed in transactions.
|
||||
pub type SignedPayload = generic::SignedPayload<RuntimeCall, TxExtension>;
|
||||
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, TxExtension>;
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive = frame_executive::Executive<
|
||||
Runtime,
|
||||
@@ -2543,106 +2530,6 @@ mod mmr {
|
||||
pub type Hashing = <Runtime as pallet_mmr::Config>::Hashing;
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub struct AssetConversionTxHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pallet_asset_conversion_tx_payment::BenchmarkHelperTrait<AccountId, u32, u32>
|
||||
for AssetConversionTxHelper
|
||||
{
|
||||
fn create_asset_id_parameter(seed: u32) -> (u32, u32) {
|
||||
(seed, seed)
|
||||
}
|
||||
|
||||
fn setup_balances_and_pool(asset_id: u32, account: AccountId) {
|
||||
use frame_support::{assert_ok, traits::fungibles::Mutate};
|
||||
assert_ok!(Assets::force_create(
|
||||
RuntimeOrigin::root(),
|
||||
asset_id.into(),
|
||||
account.clone().into(), /* owner */
|
||||
true, /* is_sufficient */
|
||||
1,
|
||||
));
|
||||
|
||||
let lp_provider = account.clone();
|
||||
let _ = Balances::deposit_creating(&lp_provider, ((u64::MAX as u128) * 100).into());
|
||||
assert_ok!(Assets::mint_into(
|
||||
asset_id.into(),
|
||||
&lp_provider,
|
||||
((u64::MAX as u128) * 100).into()
|
||||
));
|
||||
|
||||
let token_native = Box::new(NativeOrWithId::Native);
|
||||
let token_second = Box::new(NativeOrWithId::WithId(asset_id));
|
||||
|
||||
assert_ok!(AssetConversion::create_pool(
|
||||
RuntimeOrigin::signed(lp_provider.clone()),
|
||||
token_native.clone(),
|
||||
token_second.clone()
|
||||
));
|
||||
|
||||
assert_ok!(AssetConversion::add_liquidity(
|
||||
RuntimeOrigin::signed(lp_provider.clone()),
|
||||
token_native,
|
||||
token_second,
|
||||
u64::MAX.into(), // 1 desired
|
||||
u64::MAX.into(), // 2 desired
|
||||
1, // 1 min
|
||||
1, // 2 min
|
||||
lp_provider,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub struct AssetTxHelper;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl pallet_asset_tx_payment::BenchmarkHelperTrait<AccountId, u32, u32> for AssetTxHelper {
|
||||
fn create_asset_id_parameter(seed: u32) -> (u32, u32) {
|
||||
(seed, seed)
|
||||
}
|
||||
|
||||
fn setup_balances_and_pool(asset_id: u32, account: AccountId) {
|
||||
use frame_support::{assert_ok, traits::fungibles::Mutate};
|
||||
assert_ok!(Assets::force_create(
|
||||
RuntimeOrigin::root(),
|
||||
asset_id.into(),
|
||||
account.clone().into(), /* owner */
|
||||
true, /* is_sufficient */
|
||||
1,
|
||||
));
|
||||
|
||||
let lp_provider = account.clone();
|
||||
let _ = Balances::deposit_creating(&lp_provider, ((u64::MAX as u128) * 100).into());
|
||||
assert_ok!(Assets::mint_into(
|
||||
asset_id.into(),
|
||||
&lp_provider,
|
||||
((u64::MAX as u128) * 100).into()
|
||||
));
|
||||
|
||||
let token_native = Box::new(NativeOrWithId::Native);
|
||||
let token_second = Box::new(NativeOrWithId::WithId(asset_id));
|
||||
|
||||
assert_ok!(AssetConversion::create_pool(
|
||||
RuntimeOrigin::signed(lp_provider.clone()),
|
||||
token_native.clone(),
|
||||
token_second.clone()
|
||||
));
|
||||
|
||||
assert_ok!(AssetConversion::add_liquidity(
|
||||
RuntimeOrigin::signed(lp_provider.clone()),
|
||||
token_native,
|
||||
token_second,
|
||||
u64::MAX.into(), // 1 desired
|
||||
u64::MAX.into(), // 2 desired
|
||||
1, // 1 min
|
||||
1, // 2 min
|
||||
lp_provider,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benches {
|
||||
frame_benchmarking::define_benchmarks!(
|
||||
@@ -2663,9 +2550,6 @@ mod benches {
|
||||
[tasks_example, TasksExample]
|
||||
[pallet_democracy, Democracy]
|
||||
[pallet_asset_conversion, AssetConversion]
|
||||
[pallet_asset_conversion_tx_payment, AssetConversionTxPayment]
|
||||
[pallet_asset_tx_payment, AssetTxPayment]
|
||||
[pallet_transaction_payment, TransactionPayment]
|
||||
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
|
||||
[pallet_election_provider_support_benchmarking, EPSBench::<Runtime>]
|
||||
[pallet_elections_phragmen, Elections]
|
||||
@@ -2699,7 +2583,6 @@ mod benches {
|
||||
[pallet_state_trie_migration, StateTrieMigration]
|
||||
[pallet_sudo, Sudo]
|
||||
[frame_system, SystemBench::<Runtime>]
|
||||
[frame_system_extensions, SystemExtensionsBench::<Runtime>]
|
||||
[pallet_timestamp, Timestamp]
|
||||
[pallet_tips, Tips]
|
||||
[pallet_transaction_storage, TransactionStorage]
|
||||
@@ -3247,7 +3130,6 @@ impl_runtime_apis! {
|
||||
use pallet_offences_benchmarking::Pallet as OffencesBench;
|
||||
use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
|
||||
use baseline::Pallet as BaselineBench;
|
||||
use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
|
||||
|
||||
@@ -3272,7 +3154,6 @@ impl_runtime_apis! {
|
||||
use pallet_offences_benchmarking::Pallet as OffencesBench;
|
||||
use pallet_election_provider_support_benchmarking::Pallet as EPSBench;
|
||||
use frame_system_benchmarking::Pallet as SystemBench;
|
||||
use frame_system_benchmarking::extensions::Pallet as SystemExtensionsBench;
|
||||
use baseline::Pallet as BaselineBench;
|
||||
use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench;
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ use sp_core::{ed25519, sr25519, traits::SpawnNamed, Pair, Public};
|
||||
use sp_crypto_hashing::blake2_256;
|
||||
use sp_inherents::InherentData;
|
||||
use sp_runtime::{
|
||||
generic::{ExtrinsicFormat, Preamble},
|
||||
traits::{Block as BlockT, IdentifyAccount, Verify},
|
||||
OpaqueExtrinsic,
|
||||
};
|
||||
@@ -296,10 +295,10 @@ impl<'a> Iterator for BlockContentIterator<'a> {
|
||||
|
||||
let signed = self.keyring.sign(
|
||||
CheckedExtrinsic {
|
||||
format: ExtrinsicFormat::Signed(
|
||||
signed: Some((
|
||||
sender,
|
||||
tx_ext(0, kitchensink_runtime::ExistentialDeposit::get() + 1),
|
||||
),
|
||||
signed_extra(0, kitchensink_runtime::ExistentialDeposit::get() + 1),
|
||||
)),
|
||||
function: match self.content.block_type {
|
||||
BlockType::RandomTransfersKeepAlive =>
|
||||
RuntimeCall::Balances(BalancesCall::transfer_keep_alive {
|
||||
@@ -563,11 +562,11 @@ impl BenchKeyring {
|
||||
tx_version: u32,
|
||||
genesis_hash: [u8; 32],
|
||||
) -> UncheckedExtrinsic {
|
||||
match xt.format {
|
||||
ExtrinsicFormat::Signed(signed, tx_ext) => {
|
||||
match xt.signed {
|
||||
Some((signed, extra)) => {
|
||||
let payload = (
|
||||
xt.function,
|
||||
tx_ext.clone(),
|
||||
extra.clone(),
|
||||
spec_version,
|
||||
tx_version,
|
||||
genesis_hash,
|
||||
@@ -582,20 +581,11 @@ impl BenchKeyring {
|
||||
}
|
||||
});
|
||||
UncheckedExtrinsic {
|
||||
preamble: Preamble::Signed(
|
||||
sp_runtime::MultiAddress::Id(signed),
|
||||
signature,
|
||||
tx_ext,
|
||||
),
|
||||
signature: Some((sp_runtime::MultiAddress::Id(signed), signature, extra)),
|
||||
function: payload.0,
|
||||
}
|
||||
},
|
||||
ExtrinsicFormat::Bare =>
|
||||
UncheckedExtrinsic { preamble: Preamble::Bare, function: xt.function },
|
||||
ExtrinsicFormat::General(tx_ext) => UncheckedExtrinsic {
|
||||
preamble: sp_runtime::generic::Preamble::General(tx_ext),
|
||||
function: xt.function,
|
||||
},
|
||||
None => UncheckedExtrinsic { signature: None, function: xt.function },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
//! Test accounts.
|
||||
|
||||
use codec::Encode;
|
||||
use kitchensink_runtime::{CheckedExtrinsic, SessionKeys, TxExtension, UncheckedExtrinsic};
|
||||
use kitchensink_runtime::{CheckedExtrinsic, SessionKeys, SignedExtra, UncheckedExtrinsic};
|
||||
use node_cli::chain_spec::get_from_seed;
|
||||
use node_primitives::{AccountId, Balance, Nonce};
|
||||
use sp_core::{ecdsa, ed25519, sr25519};
|
||||
use sp_crypto_hashing::blake2_256;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use sp_runtime::generic::{Era, ExtrinsicFormat};
|
||||
use sp_runtime::generic::Era;
|
||||
|
||||
/// Alice's account id.
|
||||
pub fn alice() -> AccountId {
|
||||
@@ -70,18 +70,15 @@ pub fn session_keys_from_seed(seed: &str) -> SessionKeys {
|
||||
}
|
||||
|
||||
/// Returns transaction extra.
|
||||
pub fn tx_ext(nonce: Nonce, extra_fee: Balance) -> TxExtension {
|
||||
pub fn signed_extra(nonce: Nonce, extra_fee: Balance) -> SignedExtra {
|
||||
(
|
||||
(
|
||||
frame_system::CheckNonZeroSender::new(),
|
||||
frame_system::CheckSpecVersion::new(),
|
||||
frame_system::CheckTxVersion::new(),
|
||||
frame_system::CheckGenesis::new(),
|
||||
frame_system::CheckEra::from(Era::mortal(256, 0)),
|
||||
frame_system::CheckNonce::from(nonce),
|
||||
frame_system::CheckWeight::new(),
|
||||
)
|
||||
.into(),
|
||||
frame_system::CheckNonZeroSender::new(),
|
||||
frame_system::CheckSpecVersion::new(),
|
||||
frame_system::CheckTxVersion::new(),
|
||||
frame_system::CheckGenesis::new(),
|
||||
frame_system::CheckEra::from(Era::mortal(256, 0)),
|
||||
frame_system::CheckNonce::from(nonce),
|
||||
frame_system::CheckWeight::new(),
|
||||
pallet_skip_feeless_payment::SkipCheckIfFeeless::from(
|
||||
pallet_asset_conversion_tx_payment::ChargeAssetTxPayment::from(extra_fee, None),
|
||||
),
|
||||
@@ -95,10 +92,10 @@ pub fn sign(
|
||||
tx_version: u32,
|
||||
genesis_hash: [u8; 32],
|
||||
) -> UncheckedExtrinsic {
|
||||
match xt.format {
|
||||
ExtrinsicFormat::Signed(signed, tx_ext) => {
|
||||
match xt.signed {
|
||||
Some((signed, extra)) => {
|
||||
let payload =
|
||||
(xt.function, tx_ext.clone(), spec_version, tx_version, genesis_hash, genesis_hash);
|
||||
(xt.function, extra.clone(), spec_version, tx_version, genesis_hash, genesis_hash);
|
||||
let key = AccountKeyring::from_account_id(&signed).unwrap();
|
||||
let signature =
|
||||
payload
|
||||
@@ -111,21 +108,10 @@ pub fn sign(
|
||||
})
|
||||
.into();
|
||||
UncheckedExtrinsic {
|
||||
preamble: sp_runtime::generic::Preamble::Signed(
|
||||
sp_runtime::MultiAddress::Id(signed),
|
||||
signature,
|
||||
tx_ext,
|
||||
),
|
||||
signature: Some((sp_runtime::MultiAddress::Id(signed), signature, extra)),
|
||||
function: payload.0,
|
||||
}
|
||||
},
|
||||
ExtrinsicFormat::Bare => UncheckedExtrinsic {
|
||||
preamble: sp_runtime::generic::Preamble::Bare,
|
||||
function: xt.function,
|
||||
},
|
||||
ExtrinsicFormat::General(tx_ext) => UncheckedExtrinsic {
|
||||
preamble: sp_runtime::generic::Preamble::General(tx_ext),
|
||||
function: xt.function,
|
||||
},
|
||||
None => UncheckedExtrinsic { signature: None, function: xt.function },
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user