Skip to content

Commit

Permalink
Revert "FRAME: Create TransactionExtension as a replacement for `Si…
Browse files Browse the repository at this point in the history
…gnedExtension` (paritytech#2280)" (paritytech#3665)

This PR reverts paritytech#2280 which introduced `TransactionExtension` to replace
`SignedExtension`.

As a result of the discussion
[here](paritytech#3623 (comment)),
the changes will be reverted for now with plans to reintroduce the
concept in the future.

---------

Signed-off-by: georgepisaltu <george.pisaltu@parity.io>
  • Loading branch information
georgepisaltu committed Mar 13, 2024
1 parent fc89faf commit f5264c1
Show file tree
Hide file tree
Showing 176 changed files with 11,729 additions and 15,804 deletions.
2 changes: 1 addition & 1 deletion substrate/.maintain/frame-weight-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub trait WeightInfo {

/// Weights for `{{pallet}}` using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
{{#if (or (eq pallet "frame_system") (eq pallet "frame_system_extensions"))}}
{{#if (eq pallet "frame_system")}}
impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
{{else}}
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
Expand Down
2 changes: 0 additions & 2 deletions substrate/bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/cli/benches/block_production.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions substrate/bin/node/cli/benches/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
77 changes: 33 additions & 44 deletions substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
(),
(),
(),
),
);
Expand All @@ -151,7 +146,7 @@ pub fn create_extrinsic(
function,
sp_runtime::AccountId32::from(sender.public()).into(),
kitchensink_runtime::Signature::Sr25519(signature),
tx_ext,
extra,
)
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
},
);
Expand Down
26 changes: 13 additions & 13 deletions substrate/bin/node/cli/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
})
}
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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] }),
},
],
Expand Down Expand Up @@ -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,
> {
Expand All @@ -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,
Expand Down
24 changes: 9 additions & 15 deletions substrate/bin/node/cli/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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] }),
},
],
Expand Down Expand Up @@ -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()),
});

Expand Down Expand Up @@ -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,
Expand All @@ -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 }),
},
);
Expand Down Expand Up @@ -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],
}),
Expand Down
10 changes: 5 additions & 5 deletions substrate/bin/node/cli/tests/submit_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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() };
Expand Down
2 changes: 0 additions & 2 deletions substrate/bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit f5264c1

Please sign in to comment.