Skip to content

Commit

Permalink
last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellorigotti committed Feb 18, 2025
1 parent 53edd5c commit a1c974a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
6 changes: 1 addition & 5 deletions state-chain/runtime/src/chainflip/bitcoin_block_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::chainflip::bitcoin_elections::BlockDataVaultDeposit;
use pallet_cf_elections::electoral_systems::{
block_witnesser::state_machine::BWProcessorTypes, state_machine::core::Hook,
};
use pallet_cf_ingress_egress::{DepositWitness, ProcessedUpTo, VaultDepositWitness};
use pallet_cf_ingress_egress::{DepositWitness, VaultDepositWitness};

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, Deserialize, Serialize)]
pub enum BtcEvent<T> {
Expand Down Expand Up @@ -50,7 +50,6 @@ impl Hook<(BlockNumber, BtcEvent<DepositWitness<Bitcoin>>), ()> for ExecuteEvent
},
BtcEvent::Witness(deposit) => {
BitcoinIngressEgress::process_channel_deposit_full_witness(deposit, block);
ProcessedUpTo::<Runtime, BitcoinInstance>::set(block);
},
}
}
Expand All @@ -68,9 +67,6 @@ impl Hook<(BlockNumber, BtcEvent<VaultDepositWitness<Runtime, BitcoinInstance>>)
},
BtcEvent::Witness(deposit) => {
BitcoinIngressEgress::process_vault_swap_request_full_witness(block, deposit);
// How do we decide to update this? should be done only when all the block
// processors for the given block completed
ProcessedUpTo::<Runtime, BitcoinInstance>::set(block);
},
}
}
Expand Down
12 changes: 5 additions & 7 deletions state-chain/runtime/src/chainflip/bitcoin_elections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use pallet_cf_elections::{
RunnerStorageAccess,
};
use pallet_cf_ingress_egress::{
DepositChannelDetails, DepositWitness, PalletSafeMode, ProcessedUpTo, VaultDepositWitness,
DepositChannelDetails, DepositWitness, PalletSafeMode, VaultDepositWitness,
};
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -482,18 +482,16 @@ impl
RunnerStorageAccess<Runtime, BitcoinInstance>,
>,
>(vault_deposits_identifiers.clone(), &chain_progress)?;
// We use `ProcessedUpTo` as our upper limit to avoid not reaching consensus in
// case there is a reorg, using this block means safety margin will be kept into account for
// this election, and thus are much less likely to ask nodes to query for a block they don't
// have.
let last_processed_block = ProcessedUpTo::<Runtime, BitcoinInstance>::get();

let last_btc_block =
pallet_cf_chain_tracking::CurrentChainState::<Runtime, BitcoinInstance>::get().unwrap();
BitcoinLiveness::on_finalize::<
DerivedElectoralAccess<
_,
BitcoinLiveness,
RunnerStorageAccess<Runtime, BitcoinInstance>,
>,
>(liveness_identifiers, &(current_sc_block_number, last_processed_block))?;
>(liveness_identifiers, &(current_sc_block_number, last_btc_block.block_height - 3))?;

Ok(())
}
Expand Down

0 comments on commit a1c974a

Please sign in to comment.