@@ -9,8 +9,8 @@ use cosmwasm_std::{
9
9
use cw_storage_plus:: Item ;
10
10
use mesh_apis:: ibc:: {
11
11
ack_success, validate_channel_order, AckWrapper , AddValidator , AddValidatorsAck ,
12
- ConsumerPacket , DistributeAck , ProtocolVersion , ProviderPacket , RemoveValidator ,
13
- RemoveValidatorsAck ,
12
+ ConsumerPacket , DistributeAck , JailValidatorsAck , ProtocolVersion , ProviderPacket ,
13
+ RemoveValidator , RemoveValidatorsAck ,
14
14
} ;
15
15
16
16
use crate :: contract:: ExternalStakingContract ;
@@ -149,8 +149,8 @@ pub fn ibc_packet_receive(
149
149
let mut msgs = vec ! [ ] ;
150
150
for RemoveValidator {
151
151
valoper,
152
- end_height,
153
- end_time : _end_time,
152
+ height : end_height,
153
+ time : _end_time,
154
154
} in to_remove
155
155
{
156
156
// Check that the validator is active at height and slash it if that is the case
@@ -170,6 +170,32 @@ pub fn ibc_packet_receive(
170
170
let ack = ack_success ( & RemoveValidatorsAck { } ) ?;
171
171
IbcReceiveResponse :: new ( ) . set_ack ( ack) . add_messages ( msgs)
172
172
}
173
+ ConsumerPacket :: JailValidators ( to_jail) => {
174
+ let mut msgs = vec ! [ ] ;
175
+ for RemoveValidator {
176
+ valoper,
177
+ height : end_height,
178
+ time : _end_time,
179
+ } in to_jail
180
+ {
181
+ // Check that the validator is active at height and slash it if that is the case
182
+ let active = contract. val_set . is_active_validator_at_height (
183
+ deps. storage ,
184
+ & valoper,
185
+ end_height,
186
+ ) ?;
187
+ // We don't change the validator's state here, as that's currently not supported
188
+ // (only Active and Tombstoned)
189
+ if active {
190
+ // slash the validator
191
+ // TODO: Slash with a different slash ratio! (downtime / offline slash ratio)
192
+ let msg = contract. handle_slashing ( deps. storage , & valoper) ?;
193
+ msgs. push ( msg) ;
194
+ }
195
+ }
196
+ let ack = ack_success ( & JailValidatorsAck { } ) ?;
197
+ IbcReceiveResponse :: new ( ) . set_ack ( ack) . add_messages ( msgs)
198
+ }
173
199
ConsumerPacket :: Distribute { validator, rewards } => {
174
200
let contract = ExternalStakingContract :: new ( ) ;
175
201
let evt = contract. distribute_rewards ( deps, & validator, rewards) ?;
0 commit comments