@@ -215,32 +215,6 @@ func (k Keeper) HandleConsumerDowntime(ctx sdk.Context, consumerId uint64, evide
215215
216216 providerAddr := k .GetProviderAddrFromConsumerAddr (ctx , consumerId , consumerAddr )
217217
218- // Check that the consumer chain is outside its downtime grace period.
219- // During the grace period after launch, downtime evidence is suppressed to give
220- // validators time to spin up their consumer chain nodes.
221- infractionParams := k .GetInfractionParams (ctx )
222- if infractionParams .DowntimeGracePeriod > 0 {
223- initParams , err := k .GetConsumerInitializationParameters (ctx , consumerId )
224- if err != nil {
225- return errorsmod .Wrapf (
226- vaastypes .ErrInvalidConsumerState ,
227- "cannot get initialization parameters for consumer chain %d: %s" ,
228- consumerId , err ,
229- )
230- }
231- gracePeriodEnd := initParams .SpawnTime .Add (infractionParams .DowntimeGracePeriod )
232- if ctx .BlockTime ().Before (gracePeriodEnd ) {
233- return errorsmod .Wrapf (
234- vaastypes .ErrInvalidPacketData ,
235- "consumer chain %d is still in downtime grace period (launched %s, grace ends %s, now %s)" ,
236- consumerId ,
237- initParams .SpawnTime .UTC (),
238- gracePeriodEnd .UTC (),
239- ctx .BlockTime ().UTC (),
240- )
241- }
242- }
243-
244218 // Verify the infraction height is not too old.
245219 minHeight := k .GetEquivocationEvidenceMinHeight (ctx , consumerId )
246220 if uint64 (evidencePacket .InfractionHeight ) < minHeight {
@@ -265,7 +239,8 @@ func (k Keeper) HandleConsumerDowntime(ctx sdk.Context, consumerId uint64, evide
265239 }
266240
267241 consensusHeight := ibcclienttypes .NewHeight (0 , uint64 (evidencePacket .InfractionHeight ))
268- if _ , ok := k .clientKeeper .GetClientConsensusState (ctx , clientId , consensusHeight ); ! ok {
242+ consensusState , ok := k .clientKeeper .GetClientConsensusState (ctx , clientId , consensusHeight )
243+ if ! ok {
269244 return errorsmod .Wrapf (
270245 vaastypes .ErrInvalidPacketData ,
271246 "no consensus state for consumer chain %d at infraction height %d: cannot verify downtime" ,
@@ -274,6 +249,32 @@ func (k Keeper) HandleConsumerDowntime(ctx sdk.Context, consumerId uint64, evide
274249 )
275250 }
276251
252+ // Check that the consumer chain is outside its downtime grace period.
253+ // During the grace period after launch, downtime evidence is suppressed to give
254+ // validators time to spin up their consumer chain nodes.
255+ infractionParams := k .GetInfractionParams (ctx )
256+ if infractionParams .DowntimeGracePeriod > 0 {
257+ initParams , err := k .GetConsumerInitializationParameters (ctx , consumerId )
258+ if err != nil {
259+ return errorsmod .Wrapf (
260+ vaastypes .ErrInvalidConsumerState ,
261+ "cannot get initialization parameters for consumer chain %d: %s" ,
262+ consumerId , err ,
263+ )
264+ }
265+ gracePeriodEnd := initParams .SpawnTime .Add (infractionParams .DowntimeGracePeriod )
266+ if consumerTime := consensusState .GetTimestamp (); consumerTime < uint64 (gracePeriodEnd .UnixNano ()) { //nolint:staticcheck
267+ return errorsmod .Wrapf (
268+ vaastypes .ErrInvalidPacketData ,
269+ "consumer chain %d is still in downtime grace period (launched %d, grace ends %d, infraction time %d)" ,
270+ consumerId ,
271+ initParams .SpawnTime .UnixNano (),
272+ gracePeriodEnd .UnixNano (),
273+ consumerTime ,
274+ )
275+ }
276+ }
277+
277278 // Verify the validator was part of the consumer's validator set.
278279 validator , found := k .GetConsumerValidator (ctx , consumerId , providerAddr )
279280 if ! found {
0 commit comments