Skip to content

Commit 17cd663

Browse files
Seulgi Kimmergify[bot]
authored andcommitted
Fix the withdraw delay
The withdraw delay should be a term at least due to two reasons: 1. It needs the first block of the next term to calculate the penalty for the disloyal validators. 2. There is a time to report double votes of the last block. But it has no reason to be more than a term no byzantine tries to propagate double vote after 1 term. It does nothing because the chain is finalized already.
1 parent d92f008 commit 17cd663

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

core/src/consensus/stake/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ pub fn on_term_close(state: &mut TopLevelState, current_term: u64) -> StateResul
327327
}
328328
candidates.save_to_state(state)?;
329329

330-
// TODO: auto_withdraw(pending_rewards)
331-
332330
let mut jailed = Jail::load_from_state(&state)?;
333331
let released = jailed.drain_released_prisoners(current_term);
334332
for prisoner in &released {

spec/Dynamic-Validator.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
| **NOMINATION_EXPIRATION** | 24 **TERM**s |
88
| **CUSTODY_PERIOD** | 24 **TERM**s |
99
| **RELEASE_PERIOD** | 240 **TERM**s |
10-
| **WITHDRAW_DELAY** | 1 **TERM** |
1110
| **MAX_NUM_OF_VALIDATORS** | 30 |
1211
| **MIN_NUM_OF_VALIDATORS** | 4 |
1312
| **DELEGATION_THRESHOLD** | 100,000 |
@@ -105,7 +104,7 @@ The block is valid only if the sum of voting power is more than 2/3 of the total
105104

106105
## Validator Reward
107106
The block proposer gets the express fee of the blocks at the end of a term.
108-
Validators get the reward after **WITHDRAW_DELAY** terms; however, the proposers cannot get all the reward if they are not loyal to their duty.
107+
Validators get the reward after 1 term; however, the proposers cannot get all the reward if they are not loyal to their duty.
109108
The reward is decreased according to the rate of the blocks the validator misses to sign.
110109

111110
The reward is decreased when a validator doesn't sign blocks proposed by others.
@@ -142,7 +141,7 @@ for validators in total_validators {
142141
The remaining rewards as a result of the additional reward algorithm are burned.
143142
At the worst case, **MAX_NUM_OF_VALIDATORS** CCC can be burned every term.
144143

145-
The rewards the validators earn are paid after **WITHDRAW_DELAY**.
144+
The rewards the validators earn are paid after 1 term.
146145

147146
## Punishment for Validators
148147
### Downtime
@@ -202,8 +201,8 @@ The transaction fails when the delegator revokes more than it delegates.
202201
* sig2
203202

204203
This is a transaction that reports malicious validator.
205-
The **REPORT_DOUBLE_VOTE** should be reported during **WITHDRAW_DELAY**.
206-
The transaction that reports a double vote have occurred before **WITHDRAW_DELAY** fails.
204+
The **REPORT_DOUBLE_VOTE** should be reported before 1 term passes.
205+
The transaction that reports a double vote have occurred before 1 term passes fails.
207206

208207
The criminal loses all his deposit and rewards and is banned immediately; it is the only case where a validator set is changed during the term.
209208

@@ -221,7 +220,6 @@ stakeholders = [ address+ ], address asc
221220
balance(address) = quantity
222221
delegation(delegator) = [ [delegatee, quantity]+ ], delegatee asc
223222
candidates = [ [pubkey, deposits, nominate_end_at]+ ], pubkey asc
224-
pending_rewards = [ [withdraw_at, address, quantity]+ ], [withdraw_at, address] asc
225223
banned = [ address+ ], address asc
226224
jailed = [ [address, deposits, custody_until, released_at]+ ], address asc
227225
term_id = [ the last block number of the previous term, the current term id ]
@@ -232,5 +230,4 @@ intermediate_rewards = [ [ address, rewards ]+ address asc, [ address, rewards ]
232230
1. Update `term_id` to the current block number and the next term id
233231
3. Remove the expired candidates and give back the deposits
234232
3. Remove the jailed accounts if the current term is greater than `released_at` and give back the deposits
235-
4. Pay the pending rewards
236-
5. Calculate rewards and update `pending_rewards`
233+
4. Calculate rewards of the previous block and update `intermediate_rewards`

0 commit comments

Comments
 (0)