-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[XCM] Multiple FungiblesAdapter
s support + WeightTrader::buy_weight
more accurate error
#6739
Changes from all commits
b5945ee
ea32b57
9dc8504
a50366f
b1858f8
b43f230
4d83269
66de9cb
b47f25b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,16 +67,29 @@ impl WeightTrader for Tuple { | |
} | ||
|
||
fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result<Assets, XcmError> { | ||
let mut too_expensive_error_found = false; | ||
let mut last_error = None; | ||
for_tuples!( #( | ||
match Tuple.buy_weight(weight, payment.clone()) { | ||
Ok(assets) => return Ok(assets), | ||
Err(e) => { last_error = Some(e) } | ||
Err(e) => { | ||
if let XcmError::TooExpensive = e { | ||
too_expensive_error_found = true; | ||
} | ||
last_error = Some(e) | ||
} | ||
} | ||
)* ); | ||
let last_error = last_error.unwrap_or(XcmError::TooExpensive); | ||
log::trace!(target: "xcm::buy_weight", "last_error: {:?}", last_error); | ||
Err(last_error) | ||
|
||
log::trace!(target: "xcm::buy_weight", "last_error: {:?}, too_expensive_error_found: {}", last_error, too_expensive_error_found); | ||
|
||
// if we have multiple traders, and first one returns `TooExpensive` and others fail e.g. `AssetNotFound` | ||
// then it is more accurate to return `TooExpensive` then `AssetNotFound` | ||
Err(if too_expensive_error_found { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code like this is why we should actually figure out a better error reporting system for XCM, such as using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KiChjang If this change for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, no changes are necessary, I was making a general comment actually, but is definitely something that we should look into soon (one of the new hires can look into this). |
||
XcmError::TooExpensive | ||
} else { | ||
last_error.unwrap_or(XcmError::TooExpensive) | ||
}) | ||
} | ||
|
||
fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ use xcm_executor::{ | |
}; | ||
|
||
pub type SovereignAccountOf = ( | ||
SiblingParachainConvertsVia<ParaId, AccountId>, | ||
SiblingParachainConvertsVia<Sibling, AccountId>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intended? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I found it just by accident because of: https://github.com/paritytech/cumulus/pull/2167/files#diff-07287c62dd91150d975f7504bd14cc62d9889c44f7ba8ca44c30c03b05d5b071L389-R421 and I guess this was inspired by this example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It doesn't. But the change is ok - just slightly more explicit about the intent.
( |
||
AccountId32Aliases<RelayNetwork, AccountId>, | ||
ParentIsPreset<AccountId>, | ||
); | ||
|
Uh oh!
There was an error while loading. Please reload this page.