-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e5e2fa
commit 680f264
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
} |