mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Replace ExternalBlock with Batch
The initial TODO was simply to use one ExternalBlock per all batches in the block. This would require publishing ExternalBlock after the last batch, requiring knowing the last batch. While we could add such a pipeline, it'd require: 1) Initial preprocesses using a distinct message from BatchPreprocess 2) An additional message sent after all BatchPreprocess are sent Unfortunately, both would require tweaks to the SubstrateSigner which aren't worth the complexity compared to the solution here, at least, not at this time. While this will cause, if a Tributary is signing a block whose total batch data exceeds 25 kB, to use multiple transactions which could be optimized out by 'better' local data pipelining, that's an extreme edge case. Given the temporal nature of each Tributary, it's also an acceptable edge. This does no longer achieve synchrony over external blocks accordingly. While signed batches have synchrony, as they embed their block hash, batches being signed don't have cryptographic synchrony on their contents. This means validators who are eclipsed may produce invalid shares, as they sign a different batch. This will be introduced in a follow-up commit.
This commit is contained in:
@@ -229,7 +229,7 @@ pub async fn handle_application_tx<
|
||||
Pro: Processors,
|
||||
FPst: Future<Output = ()>,
|
||||
PST: Clone + Fn(ValidatorSet, Encoded) -> FPst,
|
||||
FRid: Future<Output = Vec<[u8; 32]>>,
|
||||
FRid: Future<Output = ()>,
|
||||
RID: Clone + Fn(NetworkId, [u8; 32], RecognizedIdType, [u8; 32]) -> FRid,
|
||||
>(
|
||||
tx: Transaction,
|
||||
@@ -443,11 +443,10 @@ pub async fn handle_application_tx<
|
||||
}
|
||||
}
|
||||
|
||||
Transaction::ExternalBlock(block) => {
|
||||
// Because this external block has been finalized, its batch IDs should be authorized
|
||||
for id in recognized_id(spec.set().network, genesis, RecognizedIdType::Block, block).await {
|
||||
TributaryDb::<D>::recognize_id(txn, Zone::Batch.label(), genesis, id);
|
||||
}
|
||||
Transaction::Batch(batch) => {
|
||||
// Because this Batch has achieved synchrony, its batch ID should be authorized
|
||||
TributaryDb::<D>::recognize_id(txn, Zone::Batch.label(), genesis, batch);
|
||||
recognized_id(spec.set().network, genesis, RecognizedIdType::Batch, batch).await;
|
||||
}
|
||||
|
||||
Transaction::SubstrateBlock(block) => {
|
||||
@@ -458,10 +457,7 @@ pub async fn handle_application_tx<
|
||||
|
||||
for id in plan_ids {
|
||||
TributaryDb::<D>::recognize_id(txn, Zone::Sign.label(), genesis, id);
|
||||
assert_eq!(
|
||||
recognized_id(spec.set().network, genesis, RecognizedIdType::Plan, id).await,
|
||||
vec![id]
|
||||
);
|
||||
recognized_id(spec.set().network, genesis, RecognizedIdType::Plan, id).await;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user