mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 22:55:43 +00:00
Merge remote-tracking branch 'origin/master' into gav-xcm-v3
This commit is contained in:
@@ -7,7 +7,7 @@ description = "AURA consensus extension pallet for parachains"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.132", optional = true, features = ["derive"] }
|
||||
|
||||
# Substrate
|
||||
|
||||
@@ -13,10 +13,10 @@ version = "3.0.0"
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
log = { version = "0.4.0", default-features = false }
|
||||
log = { version = "0.4.16", default-features = false }
|
||||
codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.0.0" }
|
||||
rand = { version = "0.8.5", features = ["std_rng"], default-features = false }
|
||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.132", default-features = false }
|
||||
|
||||
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -6,8 +6,8 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false }
|
||||
log = { version = "0.4.14", default-features = false }
|
||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
log = { version = "0.4.16", default-features = false }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
|
||||
# Substrate
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
@@ -9,8 +9,8 @@ description = "Base pallet for cumulus-based parachains"
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
environmental = { version = "1.1.2", default-features = false }
|
||||
impl-trait-for-tuples = "0.2.1"
|
||||
log = { version = "0.4.14", default-features = false }
|
||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
log = { version = "0.4.16", default-features = false }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.132", optional = true, features = ["derive"] }
|
||||
|
||||
# Substrate
|
||||
|
||||
@@ -9,9 +9,9 @@ description = "Proc macros provided by the parachain-system pallet"
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0.89"
|
||||
proc-macro2 = "1.0.36"
|
||||
quote = "1.0.16"
|
||||
syn = "1.0.91"
|
||||
proc-macro2 = "1.0.37"
|
||||
quote = "1.0.18"
|
||||
proc-macro-crate = "1.1.3"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -63,6 +63,10 @@ pub struct MessagingStateSnapshot {
|
||||
pub enum Error {
|
||||
/// The provided proof was created against unexpected storage root.
|
||||
RootMismatch,
|
||||
/// The entry cannot be read.
|
||||
ReadEntry(ReadEntryErr),
|
||||
/// The optional entry cannot be read.
|
||||
ReadOptionalEntry(ReadEntryErr),
|
||||
/// The slot cannot be extracted.
|
||||
Slot(ReadEntryErr),
|
||||
/// The upgrade go-ahead signal cannot be read.
|
||||
@@ -273,4 +277,28 @@ impl RelayChainStateProof {
|
||||
)
|
||||
.map_err(Error::UpgradeRestriction)
|
||||
}
|
||||
|
||||
/// Read an entry given by the key and try to decode it. If the value specified by the key according
|
||||
/// to the proof is empty, the `fallback` value will be returned.
|
||||
///
|
||||
/// Returns `Err` in case the backend can't return the value under the specific key (likely due to
|
||||
/// a malformed proof), in case the decoding fails, or in case where the value is empty in the relay
|
||||
/// chain state and no fallback was provided.
|
||||
pub fn read_entry<T>(&self, key: &[u8], fallback: Option<T>) -> Result<T, Error>
|
||||
where
|
||||
T: Decode,
|
||||
{
|
||||
read_entry(&self.trie_backend, key, fallback).map_err(Error::ReadEntry)
|
||||
}
|
||||
|
||||
/// Read an optional entry given by the key and try to decode it.
|
||||
///
|
||||
/// Returns `Err` in case the backend can't return the value under the specific key (likely due to
|
||||
/// a malformed proof) or if the value couldn't be decoded.
|
||||
pub fn read_optional_entry<T>(&self, key: &[u8]) -> Result<Option<T>, Error>
|
||||
where
|
||||
T: Decode,
|
||||
{
|
||||
read_optional_entry(&self.trie_backend, key).map_err(Error::ReadOptionalEntry)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.132", optional = true, features = ["derive"] }
|
||||
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
@@ -6,9 +6,9 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false }
|
||||
log = { version = "0.4.14", default-features = false }
|
||||
log = { version = "0.4.16", default-features = false }
|
||||
rand_chacha = { version = "0.3.0", default-features = false }
|
||||
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
|
||||
# Substrate
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
@@ -499,13 +499,15 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
|
||||
let mut s = <OutboundXcmpStatus<T>>::get();
|
||||
let index = s.iter().position(|item| item.recipient == recipient).unwrap_or_else(|| {
|
||||
let details = if let Some(details) = s.iter_mut().find(|item| item.recipient == recipient) {
|
||||
details
|
||||
} else {
|
||||
s.push(OutboundChannelDetails::new(recipient));
|
||||
s.len() - 1
|
||||
});
|
||||
let have_active = s[index].last_index > s[index].first_index;
|
||||
s.last_mut().expect("can't be empty; a new element was just pushed; qed")
|
||||
};
|
||||
let have_active = details.last_index > details.first_index;
|
||||
let appended = have_active &&
|
||||
<OutboundXcmpMessages<T>>::mutate(recipient, s[index].last_index - 1, |s| {
|
||||
<OutboundXcmpMessages<T>>::mutate(recipient, details.last_index - 1, |s| {
|
||||
if XcmpMessageFormat::decode_with_depth_limit(MAX_XCM_DECODE_DEPTH, &mut &s[..]) !=
|
||||
Ok(format)
|
||||
{
|
||||
@@ -518,15 +520,15 @@ impl<T: Config> Pallet<T> {
|
||||
return true
|
||||
});
|
||||
if appended {
|
||||
Ok((s[index].last_index - s[index].first_index - 1) as u32)
|
||||
Ok((details.last_index - details.first_index - 1) as u32)
|
||||
} else {
|
||||
// Need to add a new page.
|
||||
let page_index = s[index].last_index;
|
||||
s[index].last_index += 1;
|
||||
let page_index = details.last_index;
|
||||
details.last_index += 1;
|
||||
let mut new_page = format.encode();
|
||||
new_page.extend_from_slice(&data[..]);
|
||||
<OutboundXcmpMessages<T>>::insert(recipient, page_index, new_page);
|
||||
let r = (s[index].last_index - s[index].first_index - 1) as u32;
|
||||
let r = (details.last_index - details.first_index - 1) as u32;
|
||||
<OutboundXcmpStatus<T>>::put(s);
|
||||
Ok(r)
|
||||
}
|
||||
@@ -536,8 +538,8 @@ impl<T: Config> Pallet<T> {
|
||||
/// block.
|
||||
fn send_signal(dest: ParaId, signal: ChannelSignal) -> Result<(), ()> {
|
||||
let mut s = <OutboundXcmpStatus<T>>::get();
|
||||
if let Some(index) = s.iter().position(|item| item.recipient == dest) {
|
||||
s[index].signals_exist = true;
|
||||
if let Some(details) = s.iter_mut().find(|item| item.recipient == dest) {
|
||||
details.signals_exist = true;
|
||||
} else {
|
||||
s.push(OutboundChannelDetails::new(dest).with_signals());
|
||||
}
|
||||
@@ -602,7 +604,7 @@ impl<T: Config> Pallet<T> {
|
||||
Ok(xcm) => {
|
||||
let location = (Parent, Parachain(sender.into()));
|
||||
match T::XcmExecutor::execute_xcm(location, xcm, hash, max_weight) {
|
||||
Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)),
|
||||
Outcome::Error(e) => (Err(e), Event::Fail(Some(hash), e)),
|
||||
Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))),
|
||||
// As far as the caller is concerned, this was dispatched without error, so
|
||||
// we just report the weight used.
|
||||
@@ -657,7 +659,11 @@ impl<T: Config> Pallet<T> {
|
||||
remaining_fragments = last_remaining_fragments;
|
||||
break
|
||||
},
|
||||
Err(_) => {
|
||||
Err(error) => {
|
||||
log::error!(
|
||||
"Failed to process XCMP-XCM message, caused by {:?}",
|
||||
error
|
||||
);
|
||||
// Message looks invalid; don't attempt to retry
|
||||
},
|
||||
}
|
||||
@@ -752,7 +758,7 @@ impl<T: Config> Pallet<T> {
|
||||
let suspended = QueueSuspended::<T>::get();
|
||||
|
||||
let mut status = <InboundXcmpStatus<T>>::get(); // <- sorted.
|
||||
if status.len() == 0 {
|
||||
if status.is_empty() {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -861,10 +867,10 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
fn suspend_channel(target: ParaId) {
|
||||
<OutboundXcmpStatus<T>>::mutate(|s| {
|
||||
if let Some(index) = s.iter().position(|item| item.recipient == target) {
|
||||
let ok = s[index].state == OutboundState::Ok;
|
||||
if let Some(details) = s.iter_mut().find(|item| item.recipient == target) {
|
||||
let ok = details.state == OutboundState::Ok;
|
||||
debug_assert!(ok, "WARNING: Attempt to suspend channel that was not Ok.");
|
||||
s[index].state = OutboundState::Suspended;
|
||||
details.state = OutboundState::Suspended;
|
||||
} else {
|
||||
s.push(OutboundChannelDetails::new(target).with_suspended_state());
|
||||
}
|
||||
|
||||
@@ -65,6 +65,18 @@ fn handle_blob_message() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic = "Invalid incoming XCMP message data"]
|
||||
#[cfg(debug_assertions)]
|
||||
fn handle_invalid_data() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let data = Xcm::<Test>(vec![]).encode();
|
||||
InboundXcmpMessages::<Test>::insert(ParaId::from(1000), 1, data);
|
||||
let format = XcmpMessageFormat::ConcatenatedVersionedXcm;
|
||||
XcmpQueue::process_xcmp_message(1000.into(), (1, format), 10_000_000_000, 10_000_000_000);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn service_overweight_unknown() {
|
||||
new_test_ext().execute_with(|| {
|
||||
|
||||
Reference in New Issue
Block a user