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

feat: tainted transaction reporting #5310

Merged
merged 51 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8dcf3b1
feat: Handling of tainted transactions
Janislav Oct 1, 2024
97967bf
tests: Added tests
Janislav Oct 2, 2024
6072fee
chore: Extended LpRegistration trait + Added to Ingress/Egress config
Janislav Oct 2, 2024
89caffd
feat: Getting LP refund address
Janislav Oct 2, 2024
8706bd8
feature: ensure by lp and broker + added more tests
Janislav Oct 2, 2024
4cbcde1
refactor: Don't error if tx is tainted
Janislav Oct 4, 2024
cb6d4c3
refactor: Using DoubleMap instead of Map
Janislav Oct 4, 2024
ca6f813
refactor: Using BadOrigin + Added unit test
Janislav Oct 4, 2024
84d5182
refactor: Inline code + Add Deposit Witness to struct
Janislav Oct 7, 2024
161be64
refactor: Extended lp deposit with refund address
Janislav Oct 7, 2024
4ba1ecb
feature: Added benchmark
Janislav Oct 7, 2024
ec4ce2d
chore: Changes to benchmark
Janislav Oct 7, 2024
0af1b50
chore: generated mock weights
Janislav Oct 8, 2024
df4529e
chore: only allow mark transactions for BTC
Janislav Oct 9, 2024
8f835eb
feature: expire tainted transaction
Janislav Oct 9, 2024
8b18adf
test: refactored tests
Janislav Oct 10, 2024
961b0af
chore: Removed unused events
Janislav Oct 10, 2024
46757df
chore: Ensure only by broker
Janislav Oct 10, 2024
d61390c
chore: removed broker from tainted tx struct
Janislav Oct 10, 2024
3e4d901
chore: Only clone owner
Janislav Oct 10, 2024
c76fd40
chore: Moved tx tainted check
Janislav Oct 10, 2024
6373909
Merge branch 'main' into feature/pro-1664/close-deposit-channel
Janislav Oct 11, 2024
19feaf3
feature: Added migration for DepositChannelLookup
Janislav Oct 11, 2024
506db26
refactor: Changed data structure + fixed migrations
Janislav Oct 11, 2024
8d628ec
chore: Handle LP refund address as requirement
Janislav Oct 14, 2024
2cb9bfd
chore: Made clippy happy 🙂
Janislav Oct 14, 2024
07e76f6
chore: don't manipulate storage in place in iteration 🙅‍♂️
Janislav Oct 14, 2024
a7ad89e
test: Added migration test 🧪
Janislav Oct 14, 2024
d290643
Merge branch 'main' into feature/pro-1664/close-deposit-channel
Janislav Oct 14, 2024
b75c29c
chore: changed pallet storage version 📀
Janislav Oct 14, 2024
8f2b133
Merge branch 'main' into feature/pro-1664/close-deposit-channel
Janislav Oct 14, 2024
e9ae4a7
chore: bumped pallet storage version (again)
Janislav Oct 14, 2024
16ddff9
refactor: Changed accounting of expired transactions
Janislav Oct 16, 2024
9299e6e
refactor: using translate for migration
Janislav Oct 16, 2024
44db88a
refactor: using append, refactored test
Janislav Oct 16, 2024
6ddcb2f
feature: Added handling of boost channels
Janislav Oct 17, 2024
041b26c
feature: Marking txs when prewitness and reject when we process the depo
Janislav Oct 18, 2024
d3e78ca
feat: pre-witnessed rejection handling
dandanlen Oct 18, 2024
825c6a0
chore: Fixed logic + added tests
Janislav Oct 18, 2024
13e8841
Merge branch 'main' into feature/pro-1664/close-deposit-channel
Janislav Oct 19, 2024
9c9d636
tests: Refactor/Rearranged tests
Janislav Oct 19, 2024
53edef2
chore: Using SECONDS_PER_BLOCK instead of static block seconds
Janislav Oct 19, 2024
95e88f3
chore: Addressed comments
Janislav Oct 21, 2024
6a70d60
chore: Fixed clippy in CI
Janislav Oct 21, 2024
315b278
chore: update comments
msgmaxim Oct 22, 2024
10cdcdf
fix: don't allow report overwrite
Janislav Oct 22, 2024
326d304
chore: Renamed event
Janislav Oct 22, 2024
af46925
feat: improvements:
dandanlen Oct 22, 2024
7ef3189
Merge branch 'main' into feature/pro-1664/close-deposit-channel
Janislav Oct 22, 2024
083ebfa
fix: migration
Janislav Oct 24, 2024
c45ec0f
fix: made clippy happy
Janislav Oct 24, 2024
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
2 changes: 2 additions & 0 deletions engine/src/witness/btc/deposits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub mod tests {
address: ScriptPubkey,
) -> DepositChannelDetails<state_chain_runtime::Runtime, BitcoinInstance> {
DepositChannelDetails::<_, BitcoinInstance> {
owner: AccountId32::new([0xab; 32]),
opened_at: 1,
expires_at: 10,
deposit_channel: DepositChannel {
Expand All @@ -178,6 +179,7 @@ pub mod tests {
},
action: ChannelAction::<AccountId32>::LiquidityProvision {
lp_account: AccountId32::new([0xab; 32]),
refund_address: None,
},
boost_fee: 0,
boost_status: BoostStatus::NotBoosted,
Expand Down
37 changes: 35 additions & 2 deletions state-chain/pallets/cf-ingress-egress/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ mod benchmarks {
DepositChannelLookup::<T, I>::insert(
&deposit_address,
DepositChannelDetails {
owner: account("doogle", 0, 0),
opened_at: block_number,
expires_at: block_number,
deposit_channel:
Expand All @@ -71,6 +72,7 @@ mod benchmarks {
.unwrap(),
action: ChannelAction::<T::AccountId>::LiquidityProvision {
lp_account: account("doogle", 0, 0),
refund_address: None,
},
boost_fee: 0,
boost_status: BoostStatus::NotBoosted,
Expand Down Expand Up @@ -102,6 +104,7 @@ mod benchmarks {
let block_number = TargetChainBlockNumber::<T, I>::benchmark_value();
let mut channel =
DepositChannelDetails::<T, I> {
owner: account("doogle", 0, 0),
opened_at: block_number,
expires_at: block_number,
deposit_channel: DepositChannel::generate_new::<
Expand All @@ -110,6 +113,7 @@ mod benchmarks {
.unwrap(),
action: ChannelAction::<T::AccountId>::LiquidityProvision {
lp_account: account("doogle", 0, 0),
refund_address: None,
},
boost_fee: 0,
boost_status: BoostStatus::NotBoosted,
Expand Down Expand Up @@ -227,7 +231,10 @@ mod benchmarks {
let (_channel_id, deposit_address, ..) = Pallet::<T, I>::open_channel(
lp_account,
asset,
ChannelAction::LiquidityProvision { lp_account: lp_account.clone() },
ChannelAction::LiquidityProvision {
lp_account: lp_account.clone(),
refund_address: None,
},
fee_tier,
)
.unwrap();
Expand Down Expand Up @@ -397,7 +404,10 @@ mod benchmarks {
let (_channel_id, deposit_address, ..) = Pallet::<T, I>::open_channel(
&boosters[0],
asset,
ChannelAction::LiquidityProvision { lp_account: boosters[0].clone() },
ChannelAction::LiquidityProvision {
lp_account: boosters[0].clone(),
refund_address: None,
},
TIER_5_BPS,
)
.unwrap();
Expand Down Expand Up @@ -502,6 +512,26 @@ mod benchmarks {
assert_eq!(BoostPools::<T, I>::iter().count(), 1);
}

#[benchmark]
fn mark_transaction_as_tainted() {
let caller =
T::AccountRoleRegistry::whitelisted_caller_with_role(AccountRole::Broker).unwrap();
let tx_id = <<T as Config<I>>::TargetChain as Chain>::DepositDetails::benchmark_value();

#[block]
{
assert_ok!(Pallet::<T, I>::mark_transaction_as_tainted_inner(
RawOrigin::Signed(caller.clone()).into(),
tx_id.clone(),
));
}

assert!(
TaintedTransactions::<T, I>::get(caller, tx_id).is_some(),
"No tainted transactions found"
);
}

#[cfg(test)]
use crate::mock_eth::*;

Expand Down Expand Up @@ -546,5 +576,8 @@ mod benchmarks {
new_test_ext().execute_with(|| {
_contract_ccm_swap_request::<Test, ()>(true);
});
new_test_ext().execute_with(|| {
_mark_transaction_as_tainted::<Test, ()>(true);
});
}
}
Loading
Loading