mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
Merge branch 'master' into gav-xcm-v3
This commit is contained in:
@@ -36,12 +36,12 @@ use cumulus_primitives_core::{
|
||||
};
|
||||
use cumulus_primitives_parachain_inherent::{MessageQueueChain, ParachainInherentData};
|
||||
use frame_support::{
|
||||
dispatch::{DispatchError, DispatchResult},
|
||||
dispatch::{DispatchError, DispatchResult, Pays, PostDispatchInfo},
|
||||
ensure,
|
||||
inherent::{InherentData, InherentIdentifier, ProvideInherent},
|
||||
storage,
|
||||
traits::Get,
|
||||
weights::{Pays, PostDispatchInfo, Weight},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::{ensure_none, ensure_root};
|
||||
use polkadot_parachain::primitives::RelayChainBlockNumber;
|
||||
@@ -147,7 +147,7 @@ pub mod pallet {
|
||||
#[pallet::config]
|
||||
pub trait Config: frame_system::Config<OnSetCode = ParachainSetCode<Self>> {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Something which can be notified when the validation data is set.
|
||||
type OnSystemEvent: OnSystemEvent;
|
||||
@@ -269,7 +269,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
fn on_initialize(_n: T::BlockNumber) -> Weight {
|
||||
let mut weight = 0;
|
||||
let mut weight = Weight::zero();
|
||||
|
||||
// To prevent removing `NewValidationCode` that was set by another `on_initialize`
|
||||
// like for example from scheduler, we only kill the storage entry if it was not yet
|
||||
@@ -416,7 +416,7 @@ pub mod pallet {
|
||||
<T::OnSystemEvent as OnSystemEvent>::on_validation_data(&vfp);
|
||||
|
||||
// TODO: This is more than zero, but will need benchmarking to figure out what.
|
||||
let mut total_weight = 0;
|
||||
let mut total_weight = Weight::zero();
|
||||
total_weight += Self::process_inbound_downward_messages(
|
||||
relevant_messaging_state.dmq_mqc_head,
|
||||
downward_messages,
|
||||
@@ -808,7 +808,7 @@ impl<T: Config> Pallet<T> {
|
||||
let dm_count = downward_messages.len() as u32;
|
||||
let mut dmq_head = <LastDmqMqcHead<T>>::get();
|
||||
|
||||
let mut weight_used = 0;
|
||||
let mut weight_used = Weight::zero();
|
||||
if dm_count != 0 {
|
||||
Self::deposit_event(Event::DownwardMessagesReceived { count: dm_count });
|
||||
let max_weight =
|
||||
|
||||
@@ -25,7 +25,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
|
||||
/// Call this during the next runtime upgrade for this module.
|
||||
pub fn on_runtime_upgrade<T: Config>() -> Weight {
|
||||
let mut weight: Weight = 0;
|
||||
let mut weight: Weight = Weight::zero();
|
||||
|
||||
if StorageVersion::get::<Pallet<T>>() == 0 {
|
||||
weight = weight
|
||||
|
||||
@@ -69,12 +69,12 @@ parameter_types! {
|
||||
state_version: 1,
|
||||
};
|
||||
pub const ParachainId: ParaId = ParaId::new(200);
|
||||
pub const ReservedXcmpWeight: Weight = 0;
|
||||
pub const ReservedDmpWeight: Weight = 0;
|
||||
pub const ReservedXcmpWeight: Weight = Weight::zero();
|
||||
pub const ReservedDmpWeight: Weight = Weight::zero();
|
||||
}
|
||||
impl frame_system::Config for Test {
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
@@ -82,7 +82,7 @@ impl frame_system::Config for Test {
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type BlockLength = ();
|
||||
type BlockWeights = ();
|
||||
@@ -99,7 +99,7 @@ impl frame_system::Config for Test {
|
||||
type MaxConsumers = frame_support::traits::ConstU32<16>;
|
||||
}
|
||||
impl Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type OnSystemEvent = ();
|
||||
type SelfParaId = ParachainId;
|
||||
type OutboundXcmpMessageSource = FromThreadLocal;
|
||||
@@ -155,7 +155,7 @@ impl DmpMessageHandler for SaveIntoThreadLocal {
|
||||
for i in iter {
|
||||
m.borrow_mut().push(i);
|
||||
}
|
||||
0
|
||||
Weight::zero()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ impl XcmpMessageHandler for SaveIntoThreadLocal {
|
||||
for (sender, sent_at, message) in iter {
|
||||
m.borrow_mut().push((sender, sent_at, message.to_vec()));
|
||||
}
|
||||
0
|
||||
Weight::zero()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -403,7 +403,7 @@ fn events() {
|
||||
let events = System::events();
|
||||
assert_eq!(
|
||||
events[0].event,
|
||||
Event::ParachainSystem(crate::Event::ValidationFunctionStored.into())
|
||||
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored.into())
|
||||
);
|
||||
},
|
||||
)
|
||||
@@ -414,7 +414,7 @@ fn events() {
|
||||
let events = System::events();
|
||||
assert_eq!(
|
||||
events[0].event,
|
||||
Event::ParachainSystem(
|
||||
RuntimeEvent::ParachainSystem(
|
||||
crate::Event::ValidationFunctionApplied { relay_chain_block_num: 1234 }
|
||||
.into()
|
||||
)
|
||||
@@ -490,7 +490,7 @@ fn aborted_upgrade() {
|
||||
let events = System::events();
|
||||
assert_eq!(
|
||||
events[0].event,
|
||||
Event::ParachainSystem(crate::Event::ValidationFunctionDiscarded.into())
|
||||
RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded.into())
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -118,6 +118,11 @@ where
|
||||
let inherent_data = block
|
||||
.extrinsics()
|
||||
.iter()
|
||||
// Inherents are at the front of the block and are unsigned.
|
||||
//
|
||||
// If `is_signed` is returning `None`, we keep it safe and assume that it is "signed".
|
||||
// We are searching for unsigned transactions anyway.
|
||||
.take_while(|e| !e.is_signed().unwrap_or(true))
|
||||
.filter_map(|e| e.call().is_sub_type())
|
||||
.find_map(|c| match c {
|
||||
crate::Call::set_validation_data { data: validation_data } =>
|
||||
|
||||
@@ -251,3 +251,40 @@ fn check_inherent_fails_on_validate_block_as_expected() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_inherents_are_unsigned_and_before_all_other_extrinsics() {
|
||||
sp_tracing::try_init_simple();
|
||||
|
||||
if env::var("RUN_TEST").is_ok() {
|
||||
let (client, parent_head) = create_test_client();
|
||||
|
||||
let TestBlockData { block, validation_data } =
|
||||
build_block_with_witness(&client, Vec::new(), parent_head.clone(), Default::default());
|
||||
|
||||
let (header, mut extrinsics, proof) = block.deconstruct();
|
||||
|
||||
extrinsics.insert(0, transfer(&client, Alice, Bob, 69));
|
||||
|
||||
call_validate_block(
|
||||
parent_head,
|
||||
ParachainBlockData::new(header, extrinsics, proof),
|
||||
validation_data.relay_parent_storage_root,
|
||||
)
|
||||
.unwrap_err();
|
||||
} else {
|
||||
let output = Command::new(env::current_exe().unwrap())
|
||||
.args(&[
|
||||
"check_inherents_are_unsigned_and_before_all_other_extrinsics",
|
||||
"--",
|
||||
"--nocapture",
|
||||
])
|
||||
.env("RUN_TEST", "1")
|
||||
.output()
|
||||
.expect("Runs the test");
|
||||
assert!(output.status.success());
|
||||
|
||||
assert!(String::from_utf8(output.stderr).unwrap()
|
||||
.contains("Could not find `set_validation_data` inherent"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user