Skip to content

Commit

Permalink
removed check that spawn time is in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
insumity committed Aug 28, 2024
1 parent 2c20186 commit 25f6b82
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
5 changes: 2 additions & 3 deletions x/ccv/provider/keeper/permissionless.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,7 @@ func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool)
return time.Time{}, false
}

// a chain can only launch if the spawn time is in the future
spawnTimeInTheFuture := initializationParameters.SpawnTime.After(ctx.BlockTime())
spawnTimeIsNotZero := !initializationParameters.SpawnTime.Equal(time.Time{})

genesisHashSet := initializationParameters.GenesisHash != nil
binaryHashSet := initializationParameters.BinaryHash != nil
Expand All @@ -690,7 +689,7 @@ func (k Keeper) CanLaunch(ctx sdk.Context, consumerId string) (time.Time, bool)
blocksPerDistributionTransmissionSet := initializationParameters.BlocksPerDistributionTransmission > 0
historicalEntriesSet := initializationParameters.HistoricalEntries > 0

return initializationParameters.SpawnTime, spawnTimeInTheFuture && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet &&
return initializationParameters.SpawnTime, spawnTimeIsNotZero && genesisHashSet && binaryHashSet && consumerRedistributionFractionSet &&
blocksPerDistributionTransmissionSet && historicalEntriesSet
}

Expand Down
10 changes: 0 additions & 10 deletions x/ccv/provider/keeper/permissionless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,16 +704,6 @@ func TestCanLaunch(t *testing.T) {
_, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId")
require.True(t, canLaunch)

// initialized chain that has spawn time in the past cannot launch
ctx = ctx.WithBlockTime(initializationParameters.SpawnTime.Add(time.Second))
_, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId")
require.False(t, canLaunch)

// reset block time so the chain can launch
ctx = ctx.WithBlockTime(initializationParameters.SpawnTime.Add(-time.Second))
_, canLaunch = providerKeeper.CanLaunch(ctx, "consumerId")
require.True(t, canLaunch)

// chain cannot launch without a genesis hash
initializationParameters.GenesisHash = nil
err = providerKeeper.SetConsumerInitializationParameters(ctx, "consumerId", initializationParameters)
Expand Down

0 comments on commit 25f6b82

Please sign in to comment.