-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
- Extended DepositChannelDetails with owner field - Added extrinsic to mark transaction as tainted - Handling deposit and save details for a refund if tx is tainted
- Added tests to verify that tainted transactions can get detected for all possible swap types - Added tests to check that txs marked by other brokers are getting ignored
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5310 +/- ##
======================================
Coverage 71% 71%
======================================
Files 492 495 +3
Lines 85750 86168 +418
Branches 85750 86168 +418
======================================
+ Hits 61107 61423 +316
- Misses 21908 22002 +94
- Partials 2735 2743 +8 ☔ View full report in Codecov by Sentry. |
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.
Some early comments.
<T::TargetChain as Chain>::DepositDetails, | ||
TaintedTransactionDetails<T::AccountId>, |
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.
Consider what happens if same tx is reported twice by different parties.
I think we might need a double-map.
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.
Good point
- Taking refund address if we open a deposit channel as lp - Extended ChannelAction to take an optional refund address - Removed all dependencies regarding the LpRegistration trait (added last commit) - Refactored tests, benchmarks, etc
Still working on the benchmark. It's written, but there is something odd with the way we generate the weights. |
Also please remember to rebase against main to pick up the new compiler version. |
I took the liberty to push a commit with some updates to comments (a few things weren't quite right, and I thought it would help if I did it myself). Feel free to revert @Janislav. |
@@ -752,6 +810,26 @@ pub mod pallet { | |||
Self::recycle_channel(&mut used_weight, address); | |||
} | |||
} | |||
|
|||
// A report gets cleaned up after approx 1 hour and needs to be re-reported by the |
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.
What if the broker re-reports? Would it then overwrite the BoostRejected
record? (This would be problematic.)
- mark boosted transactions as boosted instead of using channel status - allow pallet config instead of relying on chain - add event for tx reports - only allow reporting of unseen transactions - add doc comments - renaming of types/events - remove unused error
I added some changes (From the commit description):
The main one is that I added a Boosted variant (and renamed) to the transaction report enum. I think this makes everything a bit clearer, in particular avoids having to rely on the channel status to know if a deposit has been boosted: now we just look up the tx_id. |
Somehow, the storage of the old DepositChannelDetails is not decodable during migration. No idea why yet. |
…waps-close-accounts * origin/main: (44 commits) fix: expire all previous epochs (#5279) feat: add/update contract swaps parameters (#5343) chore: add address to solana logging (#5353) fix: ignore dust underflows in order fills rpc (#5352) chore: consistent naming prewitnessed (#5351) feat: engine-runner verifies gpg signature of old dylib when downloaded (#5339) feat: tainted transaction reporting (#5310) bug: change_utxo not always present (#5340) feat: structured error return types for rpcs (#5346) chore: unify dependencies to root cargo.toml (#5333) feat: Submit a slot number alongside nonce (#5297) chore: use node version from `.nvmrc` 📌 (#5336) chore: add engine account_info logging (#5347) chore: replace manual scale encoding for ts-scale (#5335) chore: more consistent params in Broker API (#5342) feat: broker can encode btc smart contract call (#5329) chore: localnet recreate script can use defaults (#5338) feat: witnessing btc smart contract swaps (#5331) feat: Solana CCM fallback (#5316) fix: scale types for pending ceremonies (#5286) ... # Conflicts: # Cargo.lock # state-chain/chains/src/sol/api.rs # state-chain/pallets/cf-broadcast/src/migrations.rs # state-chain/pallets/cf-environment/Cargo.toml
* feat: Handling of tainted transactions - Extended DepositChannelDetails with owner field - Added extrinsic to mark transaction as tainted - Handling deposit and save details for a refund if tx is tainted * tests: Added tests - Added tests to verify that tainted transactions can get detected for all possible swap types - Added tests to check that txs marked by other brokers are getting ignored * chore: Extended LpRegistration trait + Added to Ingress/Egress config * feat: Getting LP refund address * feature: ensure by lp and broker + added more tests * refactor: Don't error if tx is tainted * refactor: Using DoubleMap instead of Map * refactor: Using BadOrigin + Added unit test * refactor: Inline code + Add Deposit Witness to struct * refactor: Extended lp deposit with refund address - Taking refund address if we open a deposit channel as lp - Extended ChannelAction to take an optional refund address - Removed all dependencies regarding the LpRegistration trait (added last commit) - Refactored tests, benchmarks, etc * feature: Added benchmark * chore: Changes to benchmark * chore: generated mock weights * chore: only allow mark transactions for BTC * feature: expire tainted transaction * test: refactored tests * chore: Removed unused events * chore: Ensure only by broker * chore: removed broker from tainted tx struct * chore: Only clone owner * chore: Moved tx tainted check * feature: Added migration for DepositChannelLookup * refactor: Changed data structure + fixed migrations * chore: Handle LP refund address as requirement * chore: Made clippy happy 🙂 * chore: don't manipulate storage in place in iteration 🙅♂️ * test: Added migration test 🧪 * chore: changed pallet storage version 📀 * chore: bumped pallet storage version (again) * refactor: Changed accounting of expired transactions * refactor: using translate for migration * refactor: using append, refactored test * feature: Added handling of boost channels * feature: Marking txs when prewitness and reject when we process the depo * feat: pre-witnessed rejection handling * chore: Fixed logic + added tests * tests: Refactor/Rearranged tests * chore: Using SECONDS_PER_BLOCK instead of static block seconds * chore: Addressed comments * chore: Fixed clippy in CI * chore: update comments * fix: don't allow report overwrite * chore: Renamed event * feat: improvements: - mark boosted transactions as boosted instead of using channel status - allow pallet config instead of relying on chain - add event for tx reports - only allow reporting of unseen transactions - add doc comments - renaming of types/events - remove unused error * fix: migration * fix: made clippy happy --------- Co-authored-by: Daniel <daniel@chainflip.io> Co-authored-by: Maxim Shishmarev <maxim@chainflip.io>
* feat: Handling of tainted transactions - Extended DepositChannelDetails with owner field - Added extrinsic to mark transaction as tainted - Handling deposit and save details for a refund if tx is tainted * tests: Added tests - Added tests to verify that tainted transactions can get detected for all possible swap types - Added tests to check that txs marked by other brokers are getting ignored * chore: Extended LpRegistration trait + Added to Ingress/Egress config * feat: Getting LP refund address * feature: ensure by lp and broker + added more tests * refactor: Don't error if tx is tainted * refactor: Using DoubleMap instead of Map * refactor: Using BadOrigin + Added unit test * refactor: Inline code + Add Deposit Witness to struct * refactor: Extended lp deposit with refund address - Taking refund address if we open a deposit channel as lp - Extended ChannelAction to take an optional refund address - Removed all dependencies regarding the LpRegistration trait (added last commit) - Refactored tests, benchmarks, etc * feature: Added benchmark * chore: Changes to benchmark * chore: generated mock weights * chore: only allow mark transactions for BTC * feature: expire tainted transaction * test: refactored tests * chore: Removed unused events * chore: Ensure only by broker * chore: removed broker from tainted tx struct * chore: Only clone owner * chore: Moved tx tainted check * feature: Added migration for DepositChannelLookup * refactor: Changed data structure + fixed migrations * chore: Handle LP refund address as requirement * chore: Made clippy happy 🙂 * chore: don't manipulate storage in place in iteration 🙅♂️ * test: Added migration test 🧪 * chore: changed pallet storage version 📀 * chore: bumped pallet storage version (again) * refactor: Changed accounting of expired transactions * refactor: using translate for migration * refactor: using append, refactored test * feature: Added handling of boost channels * feature: Marking txs when prewitness and reject when we process the depo * feat: pre-witnessed rejection handling * chore: Fixed logic + added tests * tests: Refactor/Rearranged tests * chore: Using SECONDS_PER_BLOCK instead of static block seconds * chore: Addressed comments * chore: Fixed clippy in CI * chore: update comments * fix: don't allow report overwrite * chore: Renamed event * feat: improvements: - mark boosted transactions as boosted instead of using channel status - allow pallet config instead of relying on chain - add event for tx reports - only allow reporting of unseen transactions - add doc comments - renaming of types/events - remove unused error * fix: migration * fix: made clippy happy --------- Co-authored-by: Daniel <daniel@chainflip.io> Co-authored-by: Maxim Shishmarev <maxim@chainflip.io>
* feat: Handling of tainted transactions - Extended DepositChannelDetails with owner field - Added extrinsic to mark transaction as tainted - Handling deposit and save details for a refund if tx is tainted * tests: Added tests - Added tests to verify that tainted transactions can get detected for all possible swap types - Added tests to check that txs marked by other brokers are getting ignored * chore: Extended LpRegistration trait + Added to Ingress/Egress config * feat: Getting LP refund address * feature: ensure by lp and broker + added more tests * refactor: Don't error if tx is tainted * refactor: Using DoubleMap instead of Map * refactor: Using BadOrigin + Added unit test * refactor: Inline code + Add Deposit Witness to struct * refactor: Extended lp deposit with refund address - Taking refund address if we open a deposit channel as lp - Extended ChannelAction to take an optional refund address - Removed all dependencies regarding the LpRegistration trait (added last commit) - Refactored tests, benchmarks, etc * feature: Added benchmark * chore: Changes to benchmark * chore: generated mock weights * chore: only allow mark transactions for BTC * feature: expire tainted transaction * test: refactored tests * chore: Removed unused events * chore: Ensure only by broker * chore: removed broker from tainted tx struct * chore: Only clone owner * chore: Moved tx tainted check * feature: Added migration for DepositChannelLookup * refactor: Changed data structure + fixed migrations * chore: Handle LP refund address as requirement * chore: Made clippy happy 🙂 * chore: don't manipulate storage in place in iteration 🙅♂️ * test: Added migration test 🧪 * chore: changed pallet storage version 📀 * chore: bumped pallet storage version (again) * refactor: Changed accounting of expired transactions * refactor: using translate for migration * refactor: using append, refactored test * feature: Added handling of boost channels * feature: Marking txs when prewitness and reject when we process the depo * feat: pre-witnessed rejection handling * chore: Fixed logic + added tests * tests: Refactor/Rearranged tests * chore: Using SECONDS_PER_BLOCK instead of static block seconds * chore: Addressed comments * chore: Fixed clippy in CI * chore: update comments * fix: don't allow report overwrite * chore: Renamed event * feat: improvements: - mark boosted transactions as boosted instead of using channel status - allow pallet config instead of relying on chain - add event for tx reports - only allow reporting of unseen transactions - add doc comments - renaming of types/events - remove unused error * fix: migration * fix: made clippy happy --------- Co-authored-by: Daniel <daniel@chainflip.io> Co-authored-by: Maxim Shishmarev <maxim@chainflip.io>
Pull Request
Closes: PRO-1664
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
Non-Breaking changes
If this PR includes non-breaking changes, select the
non-breaking
label. On merge, CI will automatically cherry-pick the commit to a PR against the release branch.