Skip to content

Commit

Permalink
fix: in mbt, do not set outstandingDowntime for double-sign slashes (…
Browse files Browse the repository at this point in the history
…backport #1742) (#1747)

fix: in mbt, do not set outstandingDowntime for double-sign slashes (#1742)

Fix: in mbt, do not set outstandingDowntime for double-sign slashes
(cherry picked from commit 2896f73)

Co-authored-by: Philip Offtermatt <[email protected]>
  • Loading branch information
mergify[bot] and p-offtermatt committed Apr 2, 2024
1 parent b9d5304 commit 64d5615
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/mbt/model/ccv.qnt
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,8 @@ module ccv {
})
val newConsumerState =
commitPacketOnConsumer(consumerState, packet)
// add the consumer address to the list of outstanding slashes
.with("outstandingDowntime", consumerState.outstandingDowntime.union(Set(consumerNode)))
// add the consumer address to the list of outstanding downtime if the packet is a downtime slash
.with("outstandingDowntime", if (downtime) consumerState.outstandingDowntime.add(consumerNode) else consumerState.outstandingDowntime)
Ok(currentState.with("consumerStates", currentState.consumerStates.set(consumer, newConsumerState)))
}
}
Expand Down
57 changes: 57 additions & 0 deletions tests/mbt/model/ccv_test.qnt
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,61 @@ module ccv_test {
)
res._2 == "Cannot start and stop a consumer at the same time"
}

// ===== Tests for Slashing =====
// create a base state for the slashing tests.
// set consumer "receiver" to running and set a validator set with two validators as current
// and historical validator set on provider and consumer.
// Also, make it so the consumer state has received a vsc packet from the provider.
pure val validatorSet = Map(
"validator" -> 5,
"validator2" -> 5
)
pure val vscPacket = {
id: 0,
validatorSet: validatorSet,
sendingTime: 0,
timeoutTime: 1,
downtimeSlashAcks: List()
}
pure val SlashingTestState =
GetEmptyProtocolState.with(
"providerState", GetEmptyProtocolState.providerState.with(
"chainState", GetEmptyProtocolState.providerState.chainState.with(
"currentValidatorPowers", validatorSet
).with(
"votingPowerHistory", List(validatorSet)
)
).with(
"consumerStatus", Map(
"receiver" -> RUNNING
)
)
).with(
"consumerStates", GetEmptyProtocolState.consumerStates.put(
"receiver", GetEmptyConsumerState.with(
"chainState", GetEmptyProtocolState.providerState.chainState.with(
"currentValidatorPowers", validatorSet
).with(
"votingPowerHistory", List(validatorSet)
)
).with(
"receivedVscPackets", List(vscPacket)
)
)
)

// ensure that sending a slash request for a double-sign infraction does not put outstandingDowntime in the state
run DoubleSignSlashRequestNoOutstandingDowntimeTest =
{
val result = SlashingTestState.sendSlashRequest(
"receiver",
"validator",
0,
false
)
not(result.hasError()) and
// should not have outstanding downtime, since the slash is for double-signing
result.newState.consumerStates.get("receiver").outstandingDowntime.size() == 0
}
}

0 comments on commit 64d5615

Please sign in to comment.