Skip to content

Commit

Permalink
Continue modelling partial set security
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jan 25, 2024
1 parent ec67531 commit 33ace67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tests/mbt/model/ccv.qnt
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ module ccv {
// will be added automatically.
consumersToStop: Set[Chain]): Result = {
val currentProviderState = currentState.providerState
val curValSet = currentProviderState.chainState.currentValidatorSet

// check for vsc timeouts
val timedOutConsumers = getRunningConsumers(currentProviderState).filter(
Expand All @@ -526,8 +527,8 @@ module ccv {
val currentValSets = ConsumerChains.mapBy(
(consumer) =>
currentProviderState.applyKeyAssignmentToValSet(
consumer,
currentProviderState.chainState.currentValidatorSet
consumer,
GetTopNValidatorSet(currentState, curValSet, consumer)
)
)
val newKeyAssignedValSetHistory = currentValSets.keys().mapBy(
Expand Down
21 changes: 19 additions & 2 deletions tests/mbt/model/ccv_pss.qnt
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,32 @@ module ccv_pss {
res._1
}

// Opts a validator in for a consumer chain the provider.
// Possible before the consumer chain starts running,
// and will then be applied when the consumer chain starts running.
pure def OptIn(currentState: ProtocolState, consumer: Chain, validator: Node): Result = {
pure val optedInVals = currentState.providerState.optedInVals.get(consumer)
pure val newOptedInVals = optedInVals.union(Set(validator))
{
Ok({
...currentState,
providerState: {
...currentState.providerState,
optedInVals: currentState.providerState.optedInVals.put(consumer, newOptedInVals)
}
}
})
}

// Opts a validator out. Safe to call before the consumer chain even runs.
// Will not stop the validator set from being forced to validate when in the top N.
pure def OptOut(currentState: ProtocolState, consumer: Chain, validator: Node): Result = {
pure val optedInVals = currentState.providerState.optedInVals.get(consumer)
pure val newOptedInVals = optedInVals.exclude(Set(validator))
Ok({
...currentState,
providerState: {
...currentState.providerState,
optedInVals: currentState.providerState.optedInVals.put(consumer, newOptedInVals)
}
})
}
}

0 comments on commit 33ace67

Please sign in to comment.