Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading