Skip to content

Commit

Permalink
fix: remove pre-witnessing functionality (#4358)
Browse files Browse the repository at this point in the history
* remove pre-witnessing functionality

* enable btc prewitnessing
  • Loading branch information
AlastairHolmes authored Dec 22, 2023
1 parent 6ca9226 commit 9f87824
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 95 deletions.
19 changes: 1 addition & 18 deletions engine/src/witness/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,12 @@ pub async fn process_egress<ProcessCall, ProcessingFut>(
}
}

pub async fn start<StateChainClient, ProcessCall, ProcessingFut, PrewitnessCall, PrewitnessFut>(
pub async fn start<StateChainClient, ProcessCall, ProcessingFut>(
scope: &Scope<'_, anyhow::Error>,
dot_client: DotRetryRpcClient,
process_call: ProcessCall,
prewitness_call: PrewitnessCall,
state_chain_client: Arc<StateChainClient>,
state_chain_stream: impl StateChainStreamApi + Clone,
unfinalized_state_chain_stream: impl StateChainStreamApi<false>,
epoch_source: EpochSourceBuilder<'_, '_, StateChainClient, (), ()>,
db: Arc<PersistentKeyDB>,
) -> Result<()>
Expand All @@ -192,12 +190,6 @@ where
+ Clone
+ 'static,
ProcessingFut: Future<Output = ()> + Send + 'static,
PrewitnessCall: Fn(state_chain_runtime::RuntimeCall, EpochIndex) -> PrewitnessFut
+ Send
+ Sync
+ Clone
+ 'static,
PrewitnessFut: Future<Output = ()> + Send + 'static,
{
let unfinalised_source = DotUnfinalisedSource::new(dot_client.clone())
.strictly_monotonic()
Expand Down Expand Up @@ -227,15 +219,6 @@ where

let vaults = epoch_source.vaults().await;

// Pre-witnessing
unfinalised_source
.chunk_by_vault(vaults.clone(), scope)
.deposit_addresses(scope, unfinalized_state_chain_stream, state_chain_client.clone())
.await
.dot_deposits(prewitness_call)
.logging("pre-witnessing")
.spawn(scope);

// Full witnessing
DotFinalisedSource::new(dot_client.clone())
.strictly_monotonic()
Expand Down
74 changes: 1 addition & 73 deletions engine/src/witness/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,12 @@ use anyhow::{Context, Result};

use chainflip_node::chain_spec::berghain::ETHEREUM_SAFETY_MARGIN;

pub async fn start<
StateChainClient,
StateChainStream,
ProcessCall,
ProcessingFut,
PrewitnessCall,
PrewitnessFut,
>(
pub async fn start<StateChainClient, StateChainStream, ProcessCall, ProcessingFut>(
scope: &Scope<'_, anyhow::Error>,
eth_client: EthRetryRpcClient<EthRpcSigningClient>,
process_call: ProcessCall,
prewitness_call: PrewitnessCall,
state_chain_client: Arc<StateChainClient>,
state_chain_stream: StateChainStream,
unfinalized_state_chain_stream: impl StateChainStreamApi<false>,
epoch_source: EpochSourceBuilder<'_, '_, StateChainClient, (), ()>,
db: Arc<PersistentKeyDB>,
) -> Result<()>
Expand All @@ -61,12 +52,6 @@ where
+ Clone
+ 'static,
ProcessingFut: Future<Output = ()> + Send + 'static,
PrewitnessCall: Fn(state_chain_runtime::RuntimeCall, EpochIndex) -> PrewitnessFut
+ Send
+ Sync
+ Clone
+ 'static,
PrewitnessFut: Future<Output = ()> + Send + 'static,
{
let state_chain_gateway_address = state_chain_client
.storage_value::<pallet_cf_environment::EthereumStateChainGatewayAddress<state_chain_runtime::Runtime>>(
Expand Down Expand Up @@ -126,63 +111,6 @@ where

let vaults = epoch_source.vaults().await;

// ===== Prewitnessing stream =====
let prewitness_source = eth_source.clone().chunk_by_vault(vaults.clone(), scope);

let prewitness_source_deposit_addresses = prewitness_source
.clone()
.deposit_addresses(scope, unfinalized_state_chain_stream, state_chain_client.clone())
.await;

prewitness_source_deposit_addresses
.clone()
.erc20_deposits::<_, _, _, UsdcEvents>(
prewitness_call.clone(),
eth_client.clone(),
cf_primitives::chains::assets::eth::Asset::Usdc,
usdc_contract_address,
)
.await?
.logging("pre-witnessing USDCDeposits")
.spawn(scope);

prewitness_source_deposit_addresses
.clone()
.erc20_deposits::<_, _, _, FlipEvents>(
prewitness_call.clone(),
eth_client.clone(),
cf_primitives::chains::assets::eth::Asset::Flip,
flip_contract_address,
)
.await?
.logging("pre-witnessing FlipDeposits")
.spawn(scope);

prewitness_source_deposit_addresses
.clone()
.ethereum_deposits(
prewitness_call.clone(),
eth_client.clone(),
eth::Asset::Eth,
address_checker_address,
vault_address,
)
.await
.logging("pre-witnessing EthereumDeposits")
.spawn(scope);

prewitness_source
.vault_witnessing(
prewitness_call,
eth_client.clone(),
vault_address,
cf_primitives::Asset::Eth,
cf_primitives::ForeignChain::Ethereum,
supported_erc20_tokens.clone(),
)
.logging("pre-witnessing Vault")
.spawn(scope);

// ===== Full witnessing stream =====

let eth_safety_margin = state_chain_client
Expand Down
4 changes: 0 additions & 4 deletions engine/src/witness/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ where
scope,
eth_client,
witness_call.clone(),
prewitness_call.clone(),
state_chain_client.clone(),
state_chain_stream.clone(),
unfinalised_state_chain_stream.clone(),
epoch_source.clone(),
db.clone(),
);
Expand All @@ -102,10 +100,8 @@ where
scope,
dot_client,
witness_call,
prewitness_call,
state_chain_client,
state_chain_stream,
unfinalised_state_chain_stream,
epoch_source,
db,
);
Expand Down

0 comments on commit 9f87824

Please sign in to comment.