diff --git a/pallets/market/src/lib.rs b/pallets/market/src/lib.rs index 220013aca..0884a6ea8 100644 --- a/pallets/market/src/lib.rs +++ b/pallets/market/src/lib.rs @@ -380,6 +380,10 @@ pub mod pallet { unsuccessful: BoundedVec<(DealId, DealSettlementError), MaxSettleDeals>, }, /// Deal was slashed. + /// It means that the `provider_collateral` was burned and the entire client's lockup returned. + /// + /// Currently it's emitted only when a deal was supposed to be activated on a given block, but was not. + /// [`Hooks::on_finalize`] checks deals and slashes them when necessary. DealSlashed(DealId), /// Deal has been terminated. @@ -1418,6 +1422,8 @@ pub mod pallet { log::error!(target: LOG_TARGET, "on_finalize: invariant violated, cannot slash the deal {}", deal_id); continue; }; + + Self::deposit_event(Event::::DealSlashed(deal_id)); } DealState::Active(_) => { log::info!( diff --git a/pallets/market/src/test.rs b/pallets/market/src/test.rs index 561076164..a0f622ea7 100644 --- a/pallets/market/src/test.rs +++ b/pallets/market/src/test.rs @@ -967,6 +967,16 @@ fn verifies_deals_on_block_finalization() { ); assert!(!DealsForBlock::::get(&bob_start_block).contains(&bob_deal_id)); + assert_eq!( + events(), + [ + RuntimeEvent::Balances(pallet_balances::Event::::Withdraw { + who: Market::account_id(), + amount: 15 + }), + RuntimeEvent::Market(Event::::DealSlashed(bob_deal_id)) + ] + ) }); }