This section describes an example of a simplified version of the Proof-of-Stake application. The goal of the PoS protocol is to assign voting power in the BFT consensus algorithm: users delegate their tokens to validators, the voting power of each validator is determined from the amount of tokens delegated to them. The delegated tokens are locked for a period of time, so that if the validator misbehaves, this behaviour could be tracked and reacted on by burning a part of the delegated tokens. This application can be a useful building block for other applications or, more generally, for the contexts that require a decision-making mechanism.
The party that delegates tokens to validators, expressing a certain degree of agreement with the decisions the validator makes on the user's behalf.
Pool
The account that stores (owns) delegated tokens. Can be implemented with a generic account resource kind
Validator
The party that participates in the consensus algorithm, voting for decisions. The voting power is determined by how much token the users delegate to the validator.
Create:
- Verify \(T\) kind to be the governance token kind (for both the created and consumed resource)
- A token resource \(T\) was transferred from \(T_{owner}\) to the pool:
- Consumed token resource belonged to \(T_{owner}\)
- Created token resource belongs to the pool
- \(T_{quantity}^{consumed} = T_{quantity}^{created}\)
- \(B_{quantity}\) = \(T_{quantity}\)
- \(B_{owner}\) = \(T_{owner}\)
Consume:
- A withdrawal of kind \(W\) is consumed
- Verify \(W\) kind
Create:
- A bond of kind \(B\) is consumed
- Verify \(B\) kind
- \(W_{quantity} = B_{quantity}\)
- \(W_{validator} = B_{validator}\)
- \(W_{owner}\) = \(B_{owner}\)
- \(W_{unlock} = now + U\), where \(U\) is a constant value
Consume:
- Verify \(T\) kind to be the governance token kind (for both the created and consumed resource)
- A token resource \(T\) was transferred from the pool to \(W_{owner}\):
- Consumed token resource belonged to the pool
- Created token resource belongs to \(W_{owner}\)
- \(T_{quantity}^{consumed} = T_{quantity}^{created}\)
- \(T_{quantity}\) = \(W_{quantity}*\Pi{(1 - I_{rate})}\), where \(I_{rate}\) is the infraction rate of infraction \(I\) associated with this validator (iterate over all infractions created between the delegation and \(W_{unlock}\) time)
- \(W_{owner}\) = \(T_{owner}\)
Create:
- Provided with all bonds (read data, not consumed), iterate over them and compute the voting power for each validator: \(VP_{map}[V] = \Sigma_{B_{validator} = V}{B_{quantity}}\)