You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/Dynamic-Validator.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@
43
43
9. No *SELF_NOMINATE* during **RELEASE_PERIOD**
44
44
45
45
## Term
46
-
The term is a period when one elected validator set works, and lasts for almost an hour.
46
+
A term is a period when one elected validator set works, and lasts for almost an hour.
47
47
The block that has a different generation hour from the parent block's is the last block of a term.
48
48
CodeChain elects a new validator set after all rewards of the block is given.
49
49
@@ -220,7 +220,7 @@ The transaction fails when the delegator revokes more than it delegates.
220
220
* next_delegatee
221
221
* quantity
222
222
223
-
This is an atomic version of `REVOKE (previous_delegatee, quantity)` + `DELEGATE (next_delegatee, quantity)`. It works as if two transactions are applied in a sequence, but the effect is atomic. The restrictions of the transaction are the same with both `REVOKE` and `DELGATE`.
223
+
This is an atomic version of `REVOKE (previous_delegatee, quantity)` + `DELEGATE (next_delegatee, quantity)`. It works as if two transactions are applied in a sequence, but the effect is atomic. The restrictions of the transaction are the same with both `REVOKE` and `DELEGATE`.
@@ -8,11 +8,11 @@ It is implemented as a custom action in CodeChain and enabled for the Tendermint
8
8
```
9
9
STAKING_CUSTOM_ACTION_ID = 2;
10
10
11
-
makeKey(...fragments) = rlp([
11
+
makeKey(...fragments) = blake256(rlp([
12
12
"ActionData",
13
13
STAKING_CUSTOM_ACTION_ID,
14
14
[...fragments]
15
-
])
15
+
]))
16
16
```
17
17
18
18
## List of CCS holders
@@ -47,16 +47,48 @@ makeKey(...fragments) = rlp([
47
47
A `delegatee` is an `AccountId`, and the `quantity` is a non-zero `u64` amount of CCS that a `delegator` delegated to a `delegatee`.
48
48
The RLP-encoded non-empty list should be sorted by a `delegatee` in ascending order, and every `delegatee` should be unique.
49
49
50
-
## Pending Revocations
50
+
## List of Candidates
51
51
52
-
* State Key: `makeKey("Revocations")`
52
+
* State Key: `makeKey("Candidates")`
53
+
* Value: `rlp(list of [pubkey, deposit, nominations_ends_at, metadata])`
53
54
54
-
* Value: `rlp(list of [delegator, delegatee, endTime, quantity])`
55
+
The `pubkey` is a public key of a self-nominated candidate.
56
+
The `deposit` is a `u64` amount of CCS deposited by the candidate and `nomination_ends_at` is a `u64` term id when the entry will expire.
57
+
The `metadata` is a `bytes` that can store a short amount of data that expresses or advertises themselves.
58
+
The order of it is constantly changed as the candidates send a self-nominate transaction and the term finishes.
59
+
See the 'Candidate prioritizing' section of [dynamic validator](./Dynamic-Validator.md#Candidate-prioritizing).
55
60
56
-
A `delegator` is an `AccountId` who has delegated CCS to a `delegatee`, which is also an `AccountId`.
57
-
`endTime` is a Unix time in UTC that specifies when the revocation will finally end. `quantity` is the `u64` amount of CCC that is going to be revoked.
58
-
The RLP-encoded non-empty list should be sorted by `endTime` in ascending order.
59
-
When multiple revocations have the same `endTime`, then the revocation created earlier (a block number is smaller, a transaction index is smaller) must have a smaller index.
61
+
## List of jailed accounts
62
+
63
+
* State Key: `makeKey("Jailed")`
64
+
* Value: `rlp(list of [account, deposit, custody_until, released_at])`
65
+
66
+
The `account` is an `AccountId`, and the `deposit` is a `u64` amount of CCS deposited before the candidate is jailed.
67
+
A jailed candidate can self-nominate and be removed from the list after the term id is greater or equal than a `u64` value of `custody_until`, and it is automatically removed when the term id is greater or equal than a `u64` value of `released_at`.
68
+
The RLP-encoded non-empty list should be sorted by `account` in ascending order, and every `account` should be unique.
69
+
70
+
## List of banned accounts
71
+
72
+
* State Key: `makeKey("Banned")`
73
+
* Value: `rlp(list of account)`
74
+
75
+
The `account` is an `AccountId`.
76
+
77
+
## Current validator set
78
+
79
+
* State Key: `makeKey("Validators")`
80
+
* Value: `rlp(list of [weight, delegation, deposit, pubkey])`
81
+
82
+
See 'How to update validators' section in [dynamic validator](./Dynamic-Validator.md#How-to-update-validators).
83
+
84
+
## Intermediate rewards
85
+
86
+
* State Key: `makeKey("IntermediateRewards")`
87
+
* Value: `rlp([list of [account,quantity], list of [account,quantity]])`
88
+
89
+
The `address` is an `AccountId`, and `quantity` is a `u64` value of CCC. The value is an RLP encoded list of two lists.
90
+
The first list is the rewards of the previous term, and the second list is the rewards of the current term.
91
+
Each list is sorted by `account` in ascending order, and every `account` in a list should be unique.
60
92
61
93
# Staking Actions
62
94
@@ -187,7 +219,7 @@ state = {
187
219
188
220
```
189
221
190
-
## RequestRevoke
222
+
## Revoke
191
223
192
224
### Action
193
225
@@ -196,14 +228,11 @@ state = {
196
228
- A `delegatee` is an `AccountId`.
197
229
-`quantity` is a non-zero `u64` amount of CCS to revoke from `delegatee`.
198
230
199
-
This action will queue a pending revocation rather than revoke immediately.
200
-
A pending revocation is `[delegator, delegatee, endTime, quantity]`, where `endTime` is set as the `timestamp of a block + REVOKE_PENDING_DURATION`.
201
-
A `delegator` cannot `RequestRevoke` more than the amount of delegated CCS to a `delegatee` minus the sum of the pending revocations between them.
231
+
This action will revoke delegated CCS from a `delegatee` immediately.
232
+
A `delegator` cannot `Revoke` more than the amount of delegated CCS to a `delegatee`.
-`quantity` is a `u64` amount of CCS to redelegate to `next_delegatee` from `prev_delegatee`.
296
+
297
+
Executing this action is the same as executing the revoke action and the delegate action. The `quantity` should be less than the delegated quantity of `prev_delegatee` from the sender.
Executing this action is the same as executing the revoke action and the delegate action. The `quantity` should be less than the delegated quantity of `prev_delegatee` from the sender.
341
+
See REPORT_DOUBLE_VOTE section in [Dynamic Validator](./Dynamic-Validator.md#REPORT_DOUBLE_VOTE)
326
342
327
-
### Example
343
+
## ChangeParameters
344
+
This transaction will change the common parameters when more than half of the stakeholders agree.
345
+
It does not change other fields of the scheme file because there are fields related to the genesis block.
328
346
329
-
```
347
+
It also does not provide a voting feature.
348
+
The vote initiator should collect the signatures through the off-chain.
349
+
350
+
This transaction increases the `seq` of `Metadata` and changes the `params` of `Metadata`.
351
+
The changed parameters are applied from the next block that the changing transaction is included in.
It is the list of the values that the transaction changes.
368
+
The stakeholder MUST NOT sign the transaction when the type of value is not a type that the key expected.
369
+
370
+
#### signatures
371
+
`signatures` are the ECDSA signatures of stakeholders.
372
+
The stakeholders should send the signature of `blake256(rlp_encode([ 0xFF, metadata_seq, new_parameters ]))` to the vote initiator if they agree to the change.
373
+
The transaction is valid only if more than half of the stakeholders agree.
The transaction fails if the metadata_seq is different from the `seq` of `Metadata` and is introduced to prevent replay attacks.
413
-
414
-
#### new_parameters
415
-
```
416
-
new_parameters := [ (value,)* ]
417
-
418
-
value := usize | u64 | boolean | string
419
-
```
420
-
It is the list of the values that the transaction changes.
421
-
The stakeholder MUST NOT sign the transaction when the type of value is not a type that the key expected.
422
-
423
-
#### signatures
424
-
`signatures` are the ECDSA signatures of stakeholders.
425
-
The stakeholders should send the signature of `blake256(rlp_encode([ 0xFF, metadata_seq, new_parameters ]))` to the vote initiator if they agree to the change.
426
-
The transaction is valid only if more than half of the stakeholders agree.
427
-
428
-
# Revocation
429
-
430
-
`RequestRevoke` will queue a pending revocation instead of revoking a delegation immediately.
431
-
The revocation will be delayed by a certain amount of time (`REVOKE_PENDING_DURATION`) to prevent abuse.
432
-
It will be processed when a block whose timestamp is greater than or equal to the time when `endTime` is created.
433
-
The amount of undelegated CCS of the `delegator` will be increased by `quantity` upon revocation, and the amount of delegated CCS that the `delegator` has delegated to the `delegatee` will be decreased by `quantity`, and the pending revocation will be removed from the revocation queue.
434
-
Queues and delegations that become empty should be removed from the state.
0 commit comments