Skip to content

Commit

Permalink
Start rewriting model in quint
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Aug 3, 2023
1 parent 5e5e2fa commit 680f264
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tests/difference/core/quint_model/model.qnt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// -*- mode: Bluespec; -*-
module common {
type Validator = str
type Chain = str
type Packet = int

type Timestamp = int
}

// Staking models the staking module with a single delegator, but multiple validators.
module staking {
import common.*

type Undelegation = {validator: Validator, amount: int, startTime: Timestamp}

var delegatorTokens: int
var delegationAmounts: Validator -> int
var validatorBalance: Validator -> int
var undelegationsQueue: List[Undelegation]


// Delegates an amount of tokens from the single delegator to the validator
action Delegate(validator: Validator, amount: int): bool = all {
delegatorTokens' = delegatorTokens + amount,
delegationAmounts' = delegationAmounts.setBy(validator, (oldDelegation => oldDelegation + amount)),
validatorBalance' = validatorBalance.setBy(validator, (oldBalance => oldBalance + amount))
}

// Undelegates tokens (delegated by the single delegator) from a validator.
action Undelegate(validator: Validator, amount: int): bool = any {
all {
assert(amount > delegationAmounts.get(validator)),
delegationAmounts' = delegationAmounts
},
all {
assert(amount <= delegationAmounts.get(validator)),
delegationAmounts' = delegationAmounts.setBy(validator, (oldDelegation => oldDelegation - amount)),
// TODO: call hooks for undelegate
}
}



}

module ccv_consumer {
import common.*



action ConsumerInitiatedSlash(validator: Validator, infractionHeight: int, slashType: str): bool = true

}

module main {
import common.*

pure val SlashTypes = Set("downtime", "equivocation")

action UpdateClient(chain: Chain): bool = true
action DeliverPacket(chain: Chain, packet: Packet): bool = true
action endAndBeginBlock(chain: Chain): bool = true

}

0 comments on commit 680f264

Please sign in to comment.