From 55fe27f41a919536a0813e66417fd393c32c23b8 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 22 Oct 2023 05:37:23 -0400 Subject: [PATCH] Don't allow the Bitcoin set to mint sriETH --- substrate/in-instructions/pallet/src/lib.rs | 17 ++++++++++++++--- substrate/validator-sets/pallet/src/lib.rs | 6 +----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/substrate/in-instructions/pallet/src/lib.rs b/substrate/in-instructions/pallet/src/lib.rs index 805d8f2d..5c6149ad 100644 --- a/substrate/in-instructions/pallet/src/lib.rs +++ b/substrate/in-instructions/pallet/src/lib.rs @@ -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 diff --git a/substrate/validator-sets/pallet/src/lib.rs b/substrate/validator-sets/pallet/src/lib.rs index 72183b46..7414b08b 100644 --- a/substrate/validator-sets/pallet/src/lib.rs +++ b/substrate/validator-sets/pallet/src/lib.rs @@ -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(()) } }