Skip to content

Commit

Permalink
Post-rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Jun 10, 2024
1 parent 80bb7a7 commit 1551382
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 235 deletions.
71 changes: 32 additions & 39 deletions polkadot/xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ pub mod pallet {
if Self::request_version_notify(dest).is_ok() {
// TODO: correct weights.
weight_used.saturating_accrue(T::DbWeight::get().reads_writes(1, 1));
break;
break
}
}
}
Expand Down Expand Up @@ -884,9 +884,8 @@ pub mod pallet {
timeout,
maybe_match_querier: Some(Location::here().into()),
},
VersionNotifier { origin, is_active } => {
QueryStatus::VersionNotifier { origin, is_active }
},
VersionNotifier { origin, is_active } =>
QueryStatus::VersionNotifier { origin, is_active },
Ready { response, at } => QueryStatus::Ready { response, at },
}
}
Expand Down Expand Up @@ -1690,9 +1689,8 @@ impl<T: Config> Pallet<T> {
fees,
weight_limit,
)?,
TransferType::RemoteReserve(_) => {
return Err(Error::<T>::InvalidAssetUnsupportedReserve.into())
},
TransferType::RemoteReserve(_) =>
return Err(Error::<T>::InvalidAssetUnsupportedReserve.into()),
};
FeesHandling::Separate { local_xcm, remote_xcm }
};
Expand Down Expand Up @@ -2241,7 +2239,7 @@ impl<T: Config> Pallet<T> {
}
weight_used.saturating_accrue(sv_migrate_weight);
if weight_used.any_gte(weight_cutoff) {
return (weight_used, Some(stage));
return (weight_used, Some(stage))
}
}
}
Expand All @@ -2255,7 +2253,7 @@ impl<T: Config> Pallet<T> {
}
weight_used.saturating_accrue(vn_migrate_weight);
if weight_used.any_gte(weight_cutoff) {
return (weight_used, Some(stage));
return (weight_used, Some(stage))
}
}
}
Expand All @@ -2277,7 +2275,7 @@ impl<T: Config> Pallet<T> {
// We don't early return here since we need to be certain that we
// make some progress.
weight_used.saturating_accrue(vnt_already_notified_weight);
continue;
continue
},
};
let response = Response::Version(xcm_version);
Expand All @@ -2303,7 +2301,7 @@ impl<T: Config> Pallet<T> {
weight_used.saturating_accrue(vnt_notify_weight);
if weight_used.any_gte(weight_cutoff) {
let last = Some(iter.last_raw_key().into());
return (weight_used, Some(NotifyCurrentTargets(last)));
return (weight_used, Some(NotifyCurrentTargets(last)))
}
}
stage = MigrateAndNotifyOldTargets;
Expand All @@ -2321,9 +2319,9 @@ impl<T: Config> Pallet<T> {
});
weight_used.saturating_accrue(vnt_migrate_fail_weight);
if weight_used.any_gte(weight_cutoff) {
return (weight_used, Some(stage));
return (weight_used, Some(stage))
}
continue;
continue
},
};

Expand Down Expand Up @@ -2364,7 +2362,7 @@ impl<T: Config> Pallet<T> {
weight_used.saturating_accrue(vnt_notify_migrate_weight);
}
if weight_used.any_gte(weight_cutoff) {
return (weight_used, Some(stage));
return (weight_used, Some(stage))
}
}
}
Expand Down Expand Up @@ -2690,7 +2688,7 @@ impl<T: Config> Pallet<T> {
// if migration has been already scheduled, everything is ok and data will be eventually
// migrated
if CurrentMigration::<T>::exists() {
return Ok(());
return Ok(())
}

// if migration has NOT been scheduled yet, we need to check all operational data
Expand Down Expand Up @@ -2987,7 +2985,7 @@ impl<T: Config> VersionChangeNotifier for Pallet<T> {
impl<T: Config> DropAssets for Pallet<T> {
fn drop_assets(origin: &Location, assets: AssetsInHolding, _context: &XcmContext) -> Weight {
if assets.is_empty() {
return Weight::zero();
return Weight::zero()
}
let versioned = VersionedAssets::from(Assets::from(assets));
let hash = BlakeTwo256::hash_of(&(&origin, &versioned));
Expand All @@ -3011,12 +3009,11 @@ impl<T: Config> ClaimAssets for Pallet<T> {
) -> bool {
let mut versioned = VersionedAssets::from(assets.clone());
match ticket.unpack() {
(0, [GeneralIndex(i)]) => {
(0, [GeneralIndex(i)]) =>
versioned = match versioned.into_version(*i as u32) {
Ok(v) => v,
Err(()) => return false,
}
},
},
(0, []) => (),
_ => return false,
};
Expand All @@ -3031,7 +3028,7 @@ impl<T: Config> ClaimAssets for Pallet<T> {
origin: origin.clone(),
assets: versioned,
});
return true;
return true
}
}

Expand All @@ -3042,17 +3039,15 @@ impl<T: Config> OnResponse for Pallet<T> {
querier: Option<&Location>,
) -> bool {
match Queries::<T>::get(query_id) {
Some(QueryStatus::Pending { responder, maybe_match_querier, .. }) => {
Location::try_from(responder).map_or(false, |r| origin == &r)
&& maybe_match_querier.map_or(true, |match_querier| {
Some(QueryStatus::Pending { responder, maybe_match_querier, .. }) =>
Location::try_from(responder).map_or(false, |r| origin == &r) &&
maybe_match_querier.map_or(true, |match_querier| {
Location::try_from(match_querier).map_or(false, |match_querier| {
querier.map_or(false, |q| q == &match_querier)
})
})
},
Some(QueryStatus::VersionNotifier { origin: r, .. }) => {
Location::try_from(r).map_or(false, |r| origin == &r)
},
}),
Some(QueryStatus::VersionNotifier { origin: r, .. }) =>
Location::try_from(r).map_or(false, |r| origin == &r),
_ => false,
}
}
Expand All @@ -3079,7 +3074,7 @@ impl<T: Config> OnResponse for Pallet<T> {
query_id,
expected_location: Some(o),
});
return Weight::zero();
return Weight::zero()
},
_ => {
Self::deposit_event(Event::InvalidResponder {
Expand All @@ -3088,7 +3083,7 @@ impl<T: Config> OnResponse for Pallet<T> {
expected_location: None,
});
// TODO #3735: Correct weight for this.
return Weight::zero();
return Weight::zero()
},
};
// TODO #3735: Check max_weight is correct.
Expand Down Expand Up @@ -3121,7 +3116,7 @@ impl<T: Config> OnResponse for Pallet<T> {
origin: origin.clone(),
query_id,
});
return Weight::zero();
return Weight::zero()
},
};
if querier.map_or(true, |q| q != &match_querier) {
Expand All @@ -3131,7 +3126,7 @@ impl<T: Config> OnResponse for Pallet<T> {
expected_querier: match_querier,
maybe_actual_querier: querier.cloned(),
});
return Weight::zero();
return Weight::zero()
}
}
let responder = match Location::try_from(responder) {
Expand All @@ -3141,7 +3136,7 @@ impl<T: Config> OnResponse for Pallet<T> {
origin: origin.clone(),
query_id,
});
return Weight::zero();
return Weight::zero()
},
};
if origin != responder {
Expand All @@ -3150,7 +3145,7 @@ impl<T: Config> OnResponse for Pallet<T> {
query_id,
expected_location: Some(responder),
});
return Weight::zero();
return Weight::zero()
}
return match maybe_notify {
Some((pallet_index, call_index)) => {
Expand All @@ -3172,7 +3167,7 @@ impl<T: Config> OnResponse for Pallet<T> {
max_budgeted_weight: max_weight,
};
Self::deposit_event(e);
return Weight::zero();
return Weight::zero()
}
let dispatch_origin = Origin::Response(origin.clone()).into();
match call.dispatch(dispatch_origin) {
Expand Down Expand Up @@ -3209,7 +3204,7 @@ impl<T: Config> OnResponse for Pallet<T> {
Queries::<T>::insert(query_id, QueryStatus::Ready { response, at });
Weight::zero()
},
};
}
},
_ => {
let e = Event::UnexpectedResponse { origin: origin.clone(), query_id };
Expand Down Expand Up @@ -3318,9 +3313,7 @@ where
caller.try_into().and_then(|o| match o {
Origin::Xcm(ref location)
if F::contains(&location.clone().try_into().map_err(|_| o.clone().into())?) =>
{
Ok(location.clone().try_into().map_err(|_| o.clone().into())?)
},
Ok(location.clone().try_into().map_err(|_| o.clone().into())?),
Origin::Xcm(location) => Err(Origin::Xcm(location).into()),
o => Err(o.into()),
})
Expand Down
4 changes: 2 additions & 2 deletions polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ fn run_input(xcm_messages: [XcmMessage; 5]) {
|execute_with| {
execute_with(|| {
#[cfg(feature = "try-runtime")]
parachain::AllPalletsWithSystem::try_state(Default::default()).unwrap();
parachain::AllPalletsWithSystem::try_state(Default::default(), All).unwrap();
parachain::AllPalletsWithSystem::integrity_test();
});
},
);
Relay::execute_with(|| {
#[cfg(feature = "try-runtime")]
relay_chain::AllPalletsWithSystem::try_state(Default::default()).unwrap();
relay_chain::AllPalletsWithSystem::try_state(Default::default(), All).unwrap();
relay_chain::AllPalletsWithSystem::integrity_test();
});
}
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/delegated-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ pub(crate) fn start_era(era: sp_staking::EraIndex) {
}

pub(crate) fn eq_stake(who: AccountId, total: Balance, active: Balance) -> bool {
Staking::stake(&who).unwrap() == Stake { total, active }
&& get_agent_ledger(&who).ledger.stakeable_balance() == total
Staking::stake(&who).unwrap() == Stake { total, active } &&
get_agent_ledger(&who).ledger.stakeable_balance() == total
}

pub(crate) fn get_agent_ledger(agent: &AccountId) -> AgentLedgerOuter<T> {
Expand Down
12 changes: 6 additions & 6 deletions substrate/frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl<

// Check if there are any forbidden non-inherents in the block.
if mode == ExtrinsicInclusionMode::OnlyInherents && extrinsics.len() > num_inherents {
return Err("Only inherents allowed".into());
return Err("Only inherents allowed".into())
}

let try_apply_extrinsic = |uxt: Block::Extrinsic| -> ApplyExtrinsicResult {
Expand All @@ -390,7 +390,7 @@ impl<
let r = Applyable::apply::<UnsignedValidator>(xt, &dispatch_info, encoded_len)?;

if r.is_err() && dispatch_info.class == DispatchClass::Mandatory {
return Err(InvalidTransaction::BadMandatory.into());
return Err(InvalidTransaction::BadMandatory.into())
}

<frame_system::Pallet<System>>::note_applied_extrinsic(&r, dispatch_info);
Expand All @@ -406,7 +406,7 @@ impl<
e,
err,
);
break;
break
}
}

Expand Down Expand Up @@ -776,7 +776,7 @@ impl<
/// ongoing MBMs.
fn on_idle_hook(block_number: NumberFor<Block>) {
if <System as frame_system::Config>::MultiBlockMigrator::ongoing() {
return;
return
}

let weight = <frame_system::Pallet<System>>::block_weight();
Expand Down Expand Up @@ -860,7 +860,7 @@ impl<
// The entire block should be discarded if an inherent fails to apply. Otherwise
// it may open an attack vector.
if r.is_err() && dispatch_info.class == DispatchClass::Mandatory {
return Err(InvalidTransaction::BadMandatory.into());
return Err(InvalidTransaction::BadMandatory.into())
}

<frame_system::Pallet<System>>::note_applied_extrinsic(&r, dispatch_info);
Expand Down Expand Up @@ -930,7 +930,7 @@ impl<
};

if dispatch_info.class == DispatchClass::Mandatory {
return Err(InvalidTransaction::MandatoryValidation.into());
return Err(InvalidTransaction::MandatoryValidation.into())
}

within_span! {
Expand Down
Loading

0 comments on commit 1551382

Please sign in to comment.