Skip to content

Commit

Permalink
Add more comments, remove unnecessary disjuncts
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jan 29, 2024
1 parent 98616b0 commit c94b8a2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/mbt/model/ccv_model.qnt
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,11 @@ module ccv_model {
// Every validator set on any consumer chain MUST either be or have been
// a validator set on the provider chain.
val ValidatorSetHasExistedInv =
runningConsumers.forall(chain =>
runningConsumers.forall(chain => // for all running consumers
currentState.consumerStates.get(chain).chainState.votingPowerHistory.toSet().forall(
// go through all its historical and current validator sets
validatorSet => providerValidatorHistory.toSet().contains(validatorSet)
// and check that they are also historical or current validator sets on the provider
)
)

Expand All @@ -331,10 +333,6 @@ module ccv_model {
consumer => currentState.providerState.sentVscPacketsToConsumer.get(consumer).toSet().exists(
packet => packet.validatorSet == providerValSetInCurBlock
)
// or the consumer was just started, which we detect by the consumer having a timestamp of 0
// and the consumer having the validator set that was just sent in the block
or
(currentState.consumerStates.get(consumer).chainState.lastTimestamp == 0 and currentState.consumerStates.get(consumer).chainState.currentValidatorSet == providerValSetInCurBlock)
)

// Every consumer chain receives the same sequence of
Expand Down Expand Up @@ -381,8 +379,11 @@ module ccv_model {
val lastTimeAdvancement = trace[trace.length()-1].timeAdvancement
val lastBlockTime = currentState.consumerStates.get(ConsumerWithPotentialMaturations).chainState.lastTimestamp - lastTimeAdvancement
val MatureOnTimeInv =
// if a consumer ended a block
MaturationPrecondition
implies
// then all matured packets need to have been processed and removed from the packets
// waiting to mature
currentState.consumerStates.get(ConsumerWithPotentialMaturations).maturationTimes.toSet().forall(
pair =>
val maturationTime = pair._2
Expand Down Expand Up @@ -699,9 +700,11 @@ module ccv_model {
val providerKeyAssignedValSetHistory = currentState.providerState.keyAssignedValSetHistory

val ValidatorSetHasExistedKeyAssignmentInv =
runningConsumers.forall(chain =>
runningConsumers.forall(chain => // for every running consumer
currentState.consumerStates.get(chain).chainState.votingPowerHistory.toSet().forall(
// for every validator set the consumer ever had
validatorSet => providerKeyAssignedValSetHistory.getOrElse(chain, List()).toSet().exists(
// that validator set needs to also have existed on the provider
provValSet => removeZeroPowers(provValSet) == removeZeroPowers(validatorSet)
)
)
Expand All @@ -724,10 +727,6 @@ module ccv_model {
packet.validatorSet ==
applyKeyAssignmentToValSet(providerState, consumer, providerValSetInCurBlock)
)
// or the consumer was just started, which we detect by the consumer having a timestamp of 0
// and the consumer having the validator set that was just sent in the block
or
(currentState.consumerStates.get(consumer).chainState.lastTimestamp == 0 and currentState.consumerStates.get(consumer).chainState.currentValidatorSet == providerValSetInCurBlock)
)

// Every consumer chain receives the same sequence of
Expand Down Expand Up @@ -779,6 +778,8 @@ module ccv_model {
packet.validatorSet)
}))
)
// check that the packets between the common packets are equal
// when key assignment is reversed
packetsBetween1noKeyAssignment == packetsBetween2noKeyAssignment
}
}
Expand Down

0 comments on commit c94b8a2

Please sign in to comment.