Skip to content
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

fix: dont ignore deposits #4173

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions state-chain/pallets/cf-ingress-egress/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use cf_traits::{
use frame_support::{
pallet_prelude::*,
sp_runtime::{DispatchError, Saturating, TransactionOutcome},
transactional,
};
use frame_system::pallet_prelude::*;
pub use pallet::*;
Expand Down Expand Up @@ -465,12 +466,20 @@ pub mod pallet {
deposit_witnesses
{
Self::process_single_deposit(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to make process_single_deposit transactional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is meant as a quick fix for 0.10. The "proper" change is here:
#4165

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to make process_single_deposit transactional?

Yes, good point.

deposit_address,
deposit_address.clone(),
asset,
amount,
deposit_details,
deposit_details.clone(),
block_height,
)?;
)
.unwrap_or_else(|_| {
Self::deposit_event(Event::<T, I>::DepositIgnored {
deposit_address,
asset,
amount,
deposit_details,
});
});
}
Ok(())
}
Expand Down Expand Up @@ -680,6 +689,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}

/// Completes a single deposit request.
#[transactional]
fn process_single_deposit(
deposit_address: TargetChainAccount<T, I>,
asset: TargetChainAsset<T, I>,
Expand Down
31 changes: 16 additions & 15 deletions state-chain/pallets/cf-ingress-egress/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
mock::*, Call as PalletCall, ChannelAction, ChannelIdCounter, CrossChainMessage,
DepositChannelLookup, DepositChannelPool, DepositWitness, DisabledEgressAssets, Error,
DepositChannelLookup, DepositChannelPool, DepositWitness, DisabledEgressAssets,
Event as PalletEvent, FailedVaultTransfers, FetchOrTransfer, MinimumDeposit, Pallet,
ScheduledEgressCcm, ScheduledEgressFetchOrTransfer, TargetChainAccount, VaultTransfer,
};
Expand All @@ -20,7 +20,7 @@ use cf_traits::{
DepositApi, EgressApi, GetBlockHeight,
};
use frame_support::{
assert_noop, assert_ok,
assert_ok,
traits::{Hooks, OriginTrait},
};
use sp_core::H160;
Expand Down Expand Up @@ -606,19 +606,20 @@ fn multi_use_deposit_address_different_blocks() {
.then_execute_at_next_block(|(_, deposit_address)| {
// Closing the channel should invalidate the deposit address.
IngressEgress::expire_channel(deposit_address);
assert_noop!(
IngressEgress::process_deposits(
RuntimeOrigin::root(),
vec![DepositWitness {
deposit_address,
asset: eth::Asset::Eth,
amount: 1,
deposit_details: Default::default()
}],
Default::default()
),
Error::<Test, _>::InvalidDepositAddress
);
assert_ok!(IngressEgress::process_deposits(
RuntimeOrigin::root(),
vec![DepositWitness {
deposit_address,
asset: eth::Asset::Eth,
amount: 1,
deposit_details: Default::default()
}],
Default::default()
),);
assert!(matches!(
cf_test_utilities::last_event::<Test>(),
RuntimeEvent::IngressEgress(crate::Event::DepositIgnored { .. }),
));
});
}

Expand Down
Loading