Don't allow the Bitcoin set to mint sriETH

This commit is contained in:
Luke Parker 2023-10-22 05:37:23 -04:00
parent d66a7ee43e
commit 55fe27f41a
No known key found for this signature in database
2 changed files with 15 additions and 8 deletions

View file

@ -122,9 +122,6 @@ pub mod pallet {
instructions_hash: blake2_256(&batch.instructions.encode()), instructions_hash: blake2_256(&batch.instructions.encode()),
}); });
for (i, instruction) in batch.instructions.into_iter().enumerate() { for (i, instruction) in batch.instructions.into_iter().enumerate() {
// TODO: Check this balance's coin belongs to this network
// If they don't, the validator set should be completely slashed, without question
if Self::execute(instruction).is_err() { if Self::execute(instruction).is_err() {
Self::deposit_event(Event::InstructionFailure { Self::deposit_event(Event::InstructionFailure {
network: batch.network, network: batch.network,
@ -201,6 +198,20 @@ pub mod pallet {
Err(InvalidTransaction::Future)?; Err(InvalidTransaction::Future)?;
} }
// Verify all Balances in this Batch are for this network
for instruction in &batch.batch.instructions {
// Verify this coin is for this network
// If this is ever hit, it means the validator set has turned malicious and should be fully
// slashed
// Because we have an error here, no validator set which turns malicious should execute
// this code path
// Accordingly, there's no value in writing code to fully slash the network, when such an
// even would require a runtime upgrade to fully resolve anyways
if instruction.balance.coin.network() != batch.batch.network {
Err(InvalidTransaction::Custom(0))?;
}
}
ValidTransaction::with_tag_prefix("in-instructions") ValidTransaction::with_tag_prefix("in-instructions")
.and_provides((batch.batch.network, batch.batch.id)) .and_provides((batch.batch.network, batch.batch.id))
// Set a 10 block longevity, though this should be included in the next block // Set a 10 block longevity, though this should be included in the next block

View file

@ -711,11 +711,7 @@ pub mod pallet {
account, account,
Balance { coin: Coin::Serai, amount }, Balance { coin: Coin::Serai, amount },
)?; )?;
Self::deposit_event(Event::DeallocationClaimed { Self::deposit_event(Event::DeallocationClaimed { validator: account, network, session });
validator: account,
network,
session,
});
Ok(()) Ok(())
} }
} }