-
Notifications
You must be signed in to change notification settings - Fork 15
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: ingress-egress tracking for DOT #4121
Changes from 3 commits
fd2a1f8
51e6ef8
9924ae2
156ba46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,95 @@ | ||||||
use std::sync::Arc; | ||||||
|
||||||
use cf_primitives::EpochIndex; | ||||||
use chainflip_engine::{ | ||||||
dot::retry_rpc::DotRetryRpcClient, | ||||||
settings::NodeContainer, | ||||||
state_chain_observer::client::{ | ||||||
storage_api::StorageApi, StateChainClient, StateChainStreamApi, | ||||||
}, | ||||||
witness::{ | ||||||
common::{ | ||||||
chain_source::extension::ChainSourceExt, epoch_source::EpochSourceBuilder, | ||||||
STATE_CHAIN_CONNECTION, | ||||||
}, | ||||||
dot::{filter_map_events, process_egress, proxy_added_witnessing, DotUnfinalisedSource}, | ||||||
}, | ||||||
}; | ||||||
use futures::Future; | ||||||
use utilities::task_scope::Scope; | ||||||
|
||||||
use crate::DepositTrackerSettings; | ||||||
|
||||||
use super::EnvironmentParameters; | ||||||
|
||||||
pub(super) async fn start<ProcessCall, ProcessingFut>( | ||||||
scope: &Scope<'_, anyhow::Error>, | ||||||
witness_call: ProcessCall, | ||||||
settings: DepositTrackerSettings, | ||||||
env_params: EnvironmentParameters, | ||||||
state_chain_client: Arc<StateChainClient<()>>, | ||||||
state_chain_stream: impl StateChainStreamApi + Clone, | ||||||
epoch_source: EpochSourceBuilder<'_, '_, StateChainClient<()>, (), ()>, | ||||||
) -> anyhow::Result<()> | ||||||
where | ||||||
ProcessCall: Fn(state_chain_runtime::RuntimeCall, EpochIndex) -> ProcessingFut | ||||||
+ Send | ||||||
+ Sync | ||||||
+ Clone | ||||||
+ 'static, | ||||||
ProcessingFut: Future<Output = ()> + Send + 'static, | ||||||
{ | ||||||
let dot_client = { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for this block {} |
||||||
DotRetryRpcClient::new( | ||||||
scope, | ||||||
NodeContainer { primary: settings.dot_node, backup: None }, | ||||||
env_params.dot_genesis_hash, | ||||||
)? | ||||||
}; | ||||||
|
||||||
let epoch_source = epoch_source | ||||||
.filter_map( | ||||||
|state_chain_client, _epoch_index, hash, _info| async move { | ||||||
state_chain_client | ||||||
.storage_value::<pallet_cf_environment::PolkadotVaultAccountId<state_chain_runtime::Runtime>>( | ||||||
hash, | ||||||
) | ||||||
.await | ||||||
.expect(STATE_CHAIN_CONNECTION) | ||||||
}, | ||||||
|_state_chain_client, _epoch, _block_hash, historic_info| async move { historic_info }, | ||||||
) | ||||||
.await; | ||||||
|
||||||
let vaults = epoch_source.vaults().await; | ||||||
|
||||||
DotUnfinalisedSource::new(dot_client.clone()) | ||||||
.shared(scope) | ||||||
.then(|header| async move { header.data.iter().filter_map(filter_map_events).collect() }) | ||||||
.strictly_monotonic() | ||||||
.shared(scope) | ||||||
.chunk_by_vault(vaults.clone()) | ||||||
.deposit_addresses(scope, state_chain_stream.clone(), state_chain_client.clone()) | ||||||
.await | ||||||
// Deposit witnessing | ||||||
.dot_deposits(witness_call.clone()) | ||||||
// Proxy added witnessing | ||||||
.then({ | ||||||
let witness_call = witness_call.clone(); | ||||||
move |epoch, header| proxy_added_witnessing(epoch, header, witness_call.clone()) | ||||||
}) | ||||||
// Broadcast success | ||||||
.egress_items(scope, state_chain_stream.clone(), state_chain_client.clone()) | ||||||
.await | ||||||
.then({ | ||||||
let process_call = witness_call.clone(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit for consistency
Suggested change
|
||||||
let dot_client = dot_client.clone(); | ||||||
move |epoch, header| { | ||||||
process_egress(epoch, header, process_call.clone(), dot_client.clone()) | ||||||
} | ||||||
}) | ||||||
.logging("DOT Witnessing") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for consistency
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the chain is already logged in the logging adapter which is enough for polkadot |
||||||
.spawn(scope); | ||||||
|
||||||
Ok(()) | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mod btc; | ||
pub mod common; | ||
mod dot; | ||
pub mod dot; | ||
pub mod eth; | ||
pub mod start; |
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 don't have the BTC settings loaded in here, we should probably change that to be consistent... it's weird that the settings are read from environment on each call anyway for BTC. - will create an issue, is separate to this PR: https://linear.app/chainflip/issue/PRO-916/btc-ingress-egress-tracker-settings-to-be-unified-into