From 64d5615a419034e7f668860f9f4dc9dd5d4d2449 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:34:22 +0200 Subject: [PATCH] fix: in mbt, do not set outstandingDowntime for double-sign slashes (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 2896f73efb2c0a9f4d4c23291089ec8efe8fedc4) Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> --- tests/mbt/model/ccv.qnt | 4 +-- tests/mbt/model/ccv_test.qnt | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/tests/mbt/model/ccv.qnt b/tests/mbt/model/ccv.qnt index ead7697e67..87ddc91ea2 100644 --- a/tests/mbt/model/ccv.qnt +++ b/tests/mbt/model/ccv.qnt @@ -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))) } } diff --git a/tests/mbt/model/ccv_test.qnt b/tests/mbt/model/ccv_test.qnt index cde053c420..986f8c2532 100644 --- a/tests/mbt/model/ccv_test.qnt +++ b/tests/mbt/model/ccv_test.qnt @@ -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 + } } \ No newline at end of file