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()),
});
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() {
Self::deposit_event(Event::InstructionFailure {
network: batch.network,
@ -201,6 +198,20 @@ pub mod pallet {
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")
.and_provides((batch.batch.network, batch.batch.id))
// Set a 10 block longevity, though this should be included in the next block

View file

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