mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +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:
@@ -231,9 +231,8 @@ pub enum Transaction {
|
||||
},
|
||||
DkgConfirmed(u32, [u8; 32], Signed),
|
||||
|
||||
// When an external block is finalized, we can allow the associated batch IDs
|
||||
// Commits to the full block so eclipsed nodes don't continue on their eclipsed state
|
||||
ExternalBlock([u8; 32]),
|
||||
// When we have synchrony on a batch, we can allow signing it
|
||||
Batch([u8; 32]),
|
||||
// When a Serai block is finalized, with the contained batches, we can allow the associated plan
|
||||
// IDs
|
||||
SubstrateBlock(u64),
|
||||
@@ -332,9 +331,9 @@ impl ReadWrite for Transaction {
|
||||
}
|
||||
|
||||
3 => {
|
||||
let mut block = [0; 32];
|
||||
reader.read_exact(&mut block)?;
|
||||
Ok(Transaction::ExternalBlock(block))
|
||||
let mut batch = [0; 32];
|
||||
reader.read_exact(&mut batch)?;
|
||||
Ok(Transaction::Batch(batch))
|
||||
}
|
||||
|
||||
4 => {
|
||||
@@ -431,9 +430,9 @@ impl ReadWrite for Transaction {
|
||||
signed.write(writer)
|
||||
}
|
||||
|
||||
Transaction::ExternalBlock(block) => {
|
||||
Transaction::Batch(batch) => {
|
||||
writer.write_all(&[3])?;
|
||||
writer.write_all(block)
|
||||
writer.write_all(batch)
|
||||
}
|
||||
|
||||
Transaction::SubstrateBlock(block) => {
|
||||
@@ -476,7 +475,7 @@ impl TransactionTrait for Transaction {
|
||||
Transaction::DkgShares { signed, .. } => TransactionKind::Signed(signed),
|
||||
Transaction::DkgConfirmed(_, _, signed) => TransactionKind::Signed(signed),
|
||||
|
||||
Transaction::ExternalBlock(_) => TransactionKind::Provided("external"),
|
||||
Transaction::Batch(_) => TransactionKind::Provided("batch"),
|
||||
Transaction::SubstrateBlock(_) => TransactionKind::Provided("serai"),
|
||||
|
||||
Transaction::BatchPreprocess(data) => TransactionKind::Signed(&data.signed),
|
||||
@@ -535,7 +534,7 @@ impl Transaction {
|
||||
Transaction::DkgShares { ref mut signed, .. } => signed,
|
||||
Transaction::DkgConfirmed(_, _, ref mut signed) => signed,
|
||||
|
||||
Transaction::ExternalBlock(_) => panic!("signing ExternalBlock"),
|
||||
Transaction::Batch(_) => panic!("signing Batch"),
|
||||
Transaction::SubstrateBlock(_) => panic!("signing SubstrateBlock"),
|
||||
|
||||
Transaction::BatchPreprocess(ref mut data) => &mut data.signed,
|
||||
|
||||
Reference in New Issue
Block a user