Improve batch handling (#316)

* restrict batch size to ~25kb

* add batch size check to node

* rate limit batches to 1 per serai block

* add support for multiple batches for block

* fix review comments

* Misc fixes

Doesn't yet update tests/processor until data flow is inspected.

* Move the block from SignId to ProcessorMessage::BatchPreprocesses

* Misc clean up

---------

Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
akildemir
2023-08-14 18:57:38 +03:00
committed by GitHub
parent a3441a6871
commit e680eabb62
17 changed files with 234 additions and 155 deletions

View File

@@ -535,7 +535,7 @@ pub async fn handle_processors<D: Db, Pro: Processors, P: P2p>(
Some(Transaction::SubstrateBlock(block))
}
coordinator::ProcessorMessage::BatchPreprocess { id, preprocess } => {
coordinator::ProcessorMessage::BatchPreprocess { id, block, preprocess } => {
// If this is the first attempt instance, synchronize around the block first
if id.attempt == 0 {
// Save the preprocess to disk so we can publish it later
@@ -545,7 +545,9 @@ pub async fn handle_processors<D: Db, Pro: Processors, P: P2p>(
MainDb::<D>::save_first_preprocess(&mut txn, id.id, preprocess);
txn.commit();
Some(Transaction::ExternalBlock(id.id))
// TODO: This will publish one ExternalBlock per Batch. We should only publish one per
// all batches within a block
Some(Transaction::ExternalBlock(block.0))
} else {
Some(Transaction::BatchPreprocess(SignData {
plan: id.id,