Restore block_hash to Batch

It's not only helpful (to easily check where Serai's view of the external
network is) but it's necessary in case of a non-trivial chain fork to determine
which blockchain Serai considers canonical.
This commit is contained in:
Luke Parker
2024-12-31 18:10:47 -05:00
parent 2240a50a0c
commit 6272c40561
10 changed files with 55 additions and 87 deletions

View File

@@ -11,9 +11,9 @@ use borsh::{BorshSerialize, BorshDeserialize};
use serai_db::{Get, DbTxn, Db};
use serai_primitives::{NetworkId, Coin, Amount};
use serai_validator_sets_primitives::Session;
use serai_coins_primitives::OutInstructionWithBalance;
use messages::substrate::ExecutedBatch;
use primitives::{task::*, Address, ReceivedOutput, Block, Payment};
// Logic for deciding where in its lifetime a multisig is.
@@ -444,29 +444,17 @@ impl<S: ScannerFeed> Scanner<S> {
/// `queue_burns`. Doing so will cause them to be executed multiple times.
///
/// The calls to this function must be ordered with regards to `queue_burns`.
#[allow(clippy::too_many_arguments)]
pub fn acknowledge_batch(
&mut self,
mut txn: impl DbTxn,
batch_id: u32,
publisher: Session,
in_instructions_hash: [u8; 32],
in_instruction_results: Vec<messages::substrate::InInstructionResult>,
batch: ExecutedBatch,
burns: Vec<OutInstructionWithBalance>,
key_to_activate: Option<KeyFor<S>>,
) {
log::info!("acknowledging batch {batch_id}");
log::info!("acknowledging batch {}", batch.id);
// Queue acknowledging this block via the Substrate task
substrate::queue_acknowledge_batch::<S>(
&mut txn,
batch_id,
publisher,
in_instructions_hash,
in_instruction_results,
burns,
key_to_activate,
);
substrate::queue_acknowledge_batch::<S>(&mut txn, batch, burns, key_to_activate);
// Commit this txn so this data is flushed
txn.commit();
// Then run the Substrate task