Skip to content

Commit

Permalink
ensure xcm outcome is always complete
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Nov 20, 2023
1 parent b585893 commit 9a35822
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 11 deletions.
11 changes: 8 additions & 3 deletions polkadot/xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,12 @@ pub mod pallet {
hash,
max_weight,
max_weight,
);
)
.ensure_complete()
.map_err(|error| {
log::error!(target: "runtime::xcm", "Failed execute transfer message with {:?}", error);
Error::<T>::LocalExecutionIncomplete
})?;
Self::deposit_event(Event::Attempted { outcome: outcome.clone() });
Ok(outcome)
}
Expand Down Expand Up @@ -1495,9 +1500,9 @@ impl<T: Config> Pallet<T> {
let outcome =
T::XcmExecutor::execute_xcm_in_credit(origin, local_xcm, hash, weight, weight);
Self::deposit_event(Event::Attempted { outcome: outcome.clone() });
if let Some(remote_xcm) = remote_xcm {
outcome.ensure_complete().map_err(|_| Error::<T>::LocalExecutionIncomplete)?;
outcome.ensure_complete().map_err(|_| Error::<T>::LocalExecutionIncomplete)?;

if let Some(remote_xcm) = remote_xcm {
let (ticket, price) = validate_send::<T::XcmRouter>(dest, remote_xcm.clone())
.map_err(Error::<T>::from)?;
if origin != Here.into_location() {
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/procedural/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
fn ui() {
// Only run the ui tests when `RUN_UI_TESTS` is set.
if std::env::var("RUN_UI_TESTS").is_err() {
return;
return
}

// As trybuild is using `cargo check`, we don't need the real WASM binaries.
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/chain-spec/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ fn json_eval_value_at_key(
fun: &dyn Fn(&json::Value) -> bool,
) -> bool {
let Some(key) = path.pop_front() else {
return false;
return false
};

if path.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ impl<Block: BlockT, BE: Backend<Block>> SubscriptionsInner<Block, BE> {
// blocks.
for hash in hashes.clone() {
if !sub.contains_block(hash) {
return Err(SubscriptionManagementError::BlockHashAbsent);
return Err(SubscriptionManagementError::BlockHashAbsent)
}
}

Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ fn last_runtime_upgrade_spec_version_usage() {
// a runtime upgrade in the pipeline of being applied, you should use the spec version
// of this upgrade.
if System::last_runtime_upgrade_spec_version() > 1337 {
return Weight::zero();
return Weight::zero()
}

// Do the migration.
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/core/src/address_uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl<'a> AddressUri<'a> {
Error::in_pass(initial_input, initial_input_len - input.len())
} else {
Error::in_phrase(initial_input, initial_input_len - input.len())
});
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions substrate/primitives/core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ impl<T: Sized + AsMut<[u8]> + AsRef<[u8]> + Public + Derive> Ss58Codec for T {
fn from_string(s: &str) -> Result<Self, PublicError> {
let cap = AddressUri::parse(s)?;
if cap.pass.is_some() {
return Err(PublicError::PasswordNotAllowed);
return Err(PublicError::PasswordNotAllowed)
}
let s = cap.phrase.unwrap_or(DEV_ADDRESS);
let addr = if let Some(stripped) = s.strip_prefix("0x") {
Expand All @@ -454,7 +454,7 @@ impl<T: Sized + AsMut<[u8]> + AsRef<[u8]> + Public + Derive> Ss58Codec for T {
fn from_string_with_version(s: &str) -> Result<(Self, Ss58AddressFormat), PublicError> {
let cap = AddressUri::parse(s)?;
if cap.pass.is_some() {
return Err(PublicError::PasswordNotAllowed);
return Err(PublicError::PasswordNotAllowed)
}
let (addr, v) = Self::from_ss58check_with_version(cap.phrase.unwrap_or(DEV_ADDRESS))?;
if cap.paths.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion substrate/utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ fn generate_rerun_if_changed_instructions(
while let Some(dependency) = dependencies.pop() {
// Ignore all dev dependencies
if dependency.kind == DependencyKind::Development {
continue;
continue
}

let path_or_git_dep =
Expand Down

0 comments on commit 9a35822

Please sign in to comment.