-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
check if at least one of the transactions satisfy existential deposit #4460
base: master
Are you sure you want to change the base?
check if at least one of the transactions satisfy existential deposit #4460
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the approach looks good, only have implementation details comments
also, you should move this to a helper function because it needs to happen for DepositReserveAsset
instruction as well as DepositAsset
(it too uses does Config::AssetTransactor::deposit_asset
)
polkadot/xcm/xcm-executor/src/lib.rs
Outdated
@@ -825,7 +826,29 @@ impl<Config: config::Config> XcmExecutor<Config> { | |||
let old_holding = self.holding.clone(); | |||
let result = Config::TransactionalProcessor::process(|| { | |||
let deposited = self.holding.saturating_take(assets); | |||
let mut all_failed = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
I would use a "mirrored" boolean for clarity, smth like:
let mut all_failed = true; | |
let mut deposit_succeeded = false; |
or even better, just don't mark anything and always retry failed_deposits
/ failed_ed_deposits
- they either work or throw some error which we will simply bubble up with ?
.
polkadot/xcm/xcm-executor/src/lib.rs
Outdated
@@ -825,7 +826,29 @@ impl<Config: config::Config> XcmExecutor<Config> { | |||
let old_holding = self.holding.clone(); | |||
let result = Config::TransactionalProcessor::process(|| { | |||
let deposited = self.holding.saturating_take(assets); | |||
let mut all_failed = true; | |||
let mut failed_deposits = Vec::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut failed_deposits = Vec::new(); | |
let mut failed_ed_deposits = Vec::with_capacity(deposited.len()); |
polkadot/xcm/xcm-executor/src/lib.rs
Outdated
Ok(_) => { | ||
all_failed = false; | ||
} | ||
Err(_err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to explicitly match against the error happening because of ED not satisfied. We only want to retry on that specific error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the underlying error is lost along the way, we only get a string description.
We could either do the retry regardless of error, or match on the string description:
Err(_err) => { | |
Err(e) if matches!(e, FailedToTransactAsset("Account cannot exist with the funds that would be given")) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to go with retry for any error.
polkadot/xcm/xcm-executor/src/lib.rs
Outdated
if all_failed { | ||
return Err(XcmError::FailedToTransactAsset("")) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simply fall through to always retry any failed ones. On second try, they either all work or not.
if all_failed { | |
return Err(XcmError::FailedToTransactAsset("")) | |
} |
polkadot/xcm/xcm-executor/src/lib.rs
Outdated
all_failed = false; | ||
} | ||
Err(_err) => { | ||
// check if is not enough ED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// check if is not enough ED | |
failed_ed_deposits.push(asset); |
…rrat/depositing-multiple-assets
@acatangiu Sorry for the long delay with this one. One last thing, I'm not sure how to do the tests for this one. What do you guys usually do with the xcm executor test? |
The CI pipeline was cancelled due to failure one of the required jobs. |
Closes #4242
Hey @acatangiu, created this PR as a draft. I still have to figure things out.
Is this what you had in mind?
Which error should I return in case all transactions fail?