-
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: update custom_rpc, runtime_api and broker api for broker level screening #5341
base: main
Are you sure you want to change the base?
feat: update custom_rpc, runtime_api and broker api for broker level screening #5341
Conversation
af966d1
to
a3835f1
Compare
To be discussed: error handling in the subscription forwarding in the broker api ( |
commit 3166701 Author: Maxim Urschumzew <maxu@chainflip.io> Date: Tue Oct 29 15:27:51 2024 +0100 Add `subscribe_tainted_btc_transaction_events` method to Broker API. It which forwards the node subscription of the same name. commit 010772d Author: Maxim Urschumzew <maxu@chainflip.io> Date: Tue Oct 29 13:56:07 2024 +0100 Add `open_btc_deposit_channels` method to broker api. commit 9ea7e6f Author: Maxim Urschumzew <maxu@chainflip.io> Date: Tue Oct 29 11:19:07 2024 +0100 Add subscription endpoint for tainted transaction events. commit e81028a Author: Maxim Urschumzew <maxu@chainflip.io> Date: Mon Oct 28 15:12:47 2024 +0100 Implement `open_btc_deposit_channels`. commit 439ddd1 Author: Maxim Urschumzew <maxu@chainflip.io> Date: Mon Oct 28 14:51:22 2024 +0100 Add boilerplate for `open_btc_deposit_channels`. commit a3835f1 Author: Maxim Urschumzew <maxu@chainflip.io> Date: Mon Oct 28 10:25:51 2024 +0100 Add endpoint for marking btc tx as tainted.
3166701
to
e1a6006
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5341 +/- ##
======================================
- Coverage 72% 71% -0%
======================================
Files 497 497
Lines 86388 86285 -103
Branches 86388 86285 -103
======================================
- Hits 61785 61558 -227
- Misses 21822 21908 +86
- Partials 2781 2819 +38 ☔ 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.
Looking good - I have one larger (and very annoying) suggestion and some minor ones...
sp-rpc = { workspace = true } | ||
sc-rpc = { workspace = true, default-features = 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.
Duplicate 👀
FWIW I think sp-core should also have default-features=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.
Unfortunately one is sP-
and the other sC-
... The latter was required for the sc_rpc::utils::pipe_from_stream()
utility.
I am not sure about the default-features though, I copied it from the custom_rpc
lib. In fact it compiles if I remove the default-features=true
for sc-rpc
.
Should I enable default-features for all three of them anyways?
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 we should enable it for all three - it might not be a problem now, but this kind of thing tends to cause problems unexpectedly.
api/lib/src/lib.rs
Outdated
.submit_signed_extrinsic(state_chain_runtime::RuntimeCall::BitcoinIngressEgress( | ||
pallet_cf_ingress_egress::Call::mark_transaction_as_tainted { tx_id }, | ||
)) | ||
.await; |
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.
Can we return the result here instead of ignoring it?
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.
The return type of that .await
is (H256, (<Self as SignedExtrinsicApi>::UntilInBlockFuture, <Self as SignedExtrinsicApi>::UntilFinalizedFuture))
, I am now returning the first tx_hash: H256
element.
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.
Sorry I didn't explain very well - I meant propagating the error using ?
The return type is confusing:
The H256
is the state chain transaction hash. There is a trait implemented on the tuple that allows you to wait either until_in_block
or until_finalized()
. I think we should wait until_in_block
.
Oh yeah and we can use submit_signed_extrinsic_with_dry_run
😅 this will avoid sending the tx if it will have no effect / won't succeed.
There's a helper trait/method for all of the above: simple_submission_with_dry_run
.
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 I see, done.
In particular the new API methods are now generic over the target chain type to keep the interface as stable as possible. However, they are still only implemented for bitcoin.
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 final comments then we're good.
.filter(|channel_details| match channel_details.action { | ||
ChannelAction::Swap {..} => true, | ||
ChannelAction::CcmTransfer {..} => true, | ||
ChannelAction::LiquidityProvision {..} => false, |
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'm not sure there's a need for this filter - why ignore LiquidityProvision ?
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.
Talked with Martin: Currently we only implement the rejection of transactions which originate from swaps. The liquidity provision transactions would have to be monitored by members of the "whitelist" which are authorized to do so. We don't have the whitelist currently, so nobody monitors these transactions.
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 but this rpc is called cf_get_open_deposit_channels
so it should probably return all of the open deposit channels for the given id.
If a broker submits this request via the broker api it will implicitly filter out an LP channels anyway. And later on when we want to be able to monitor all channels, we won't get any surprises in the behaviour of this rpc.
api/lib/src/lib.rs
Outdated
.submit_signed_extrinsic(state_chain_runtime::RuntimeCall::BitcoinIngressEgress( | ||
pallet_cf_ingress_egress::Call::mark_transaction_as_tainted { tx_id }, | ||
)) | ||
.await; |
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.
Sorry I didn't explain very well - I meant propagating the error using ?
The return type is confusing:
The H256
is the state chain transaction hash. There is a trait implemented on the tuple that allows you to wait either until_in_block
or until_finalized()
. I think we should wait until_in_block
.
Oh yeah and we can use submit_signed_extrinsic_with_dry_run
😅 this will avoid sending the tx if it will have no effect / won't succeed.
There's a helper trait/method for all of the above: simple_submission_with_dry_run
.
…n_with_dry_run()`.
Pull Request
Closes: PRO-1706
Checklist
Please conduct a thorough self-review before opening the PR.
Summary
In this PR all changes to the broker API which are required for broker level screening are going to be merged. Currently based on @Janislav 's PR
(#5310)(#5332) which implements the extrinsic for rejecting transactions.Once that PR is merged, rebase this on main.
This PR includes the following changes:
custom_rpc
:cf_subscribe_tainted_btc_transaction_events
which is a subscription for all events related with tainted transactions occuring in the ingress egress pallet.cf_open_btc_deposit_channels
which returns all open channel addresses for a given account id.mark_btc_transaction_as_tainted
endpoint which submits the corresponding extrinsic.open_btc_deposit_channels
method.subscribe_tainted_btc_transaction_events
method which forwards the node subscription of the same name.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.