Repository navigation
Dynamic validator module outline #1536
Copy link
Copy link
Closed
Labels
Description
Actions
Action::TransferCCS {},
Action::DelegateCCS {},
Action::Revoke {
delegatee: Address,
quantity: u64, // CCS
},
Action::SelfNomination {
deposit: u64, // CCC
metadata: Bytes
}
Action::ReportDoubleVote {
header1: Header,
sig1: H256,
header2: Header,
sig2: H256,
}States
Existing
stakeholders = [ address+ ]
balance(address) = quantity
delegation(delegator) = [ [delegatee, quantity]+ ]
New states
candidates = [ [address, deposits, nominate_end_at]+ ], address asc
pending_rewards = [ [withdraw_at, address, quantity]+ ], [withdraw_at, address] asc
banned = [ address+ ], address asc
jailed = [ [address, deposits, custody_until, kicked_at]+ ], address asc
Action handlers
handle_self_nomination(deposit):
if sender in banned:
error
if sender in jailed:
if current_term < custody_until:
error
else:
jailed.reomve(sender)
candidates.update(sender, deposit, current_term + NOMINATE_EXPIRATION)
sender.subtract(deposit)
handle_transfer(): ...
handle_delegate(delegatee, quantity):
if sender in banned:
error
if sender not in candidates or jailed:
error
delegation(sender).add(delegatee, quantity)
handle_revoke():
delegation(sender).subtract(delegatee, quantity)
handle_double_sign(header1, sig1, header2, sig2):
if !check_sig(header1, sig1) || !check_sig(header2, sig2):
error
pending_rewards.remove(address)
candidates.remove(address)
revert_delegation(address)
validators.remove(address)
validator_order.remove(address)
jail.remove(address)
banned.push(address)
other events
jail(address):
deposit = candidates.remove(address)
validators.remove(address)
validator_order.remove(address)
jailed.add(address, deposit
current_term + CUSTODY_PERIOD,
current_term + RELEASE_PERIOD)
on_block_close():
pending_rewards.update([current_term + WITHDRAW_DELAY, address], express_fee)
on_term_close():
total_slash = slash_unresponsive(headers, pending_rewards)
pending_rewards.update(signature_reward(blocks, total_slash))
auto_expire_nominate(candidates, delegation)
auto_withdraw(pending_rewards)
kick(jailed)
validators, validator_order = elect()
Reactions are currently unavailable
Activity
foriequal0 commentedon May 20, 2019
@sgkim126 how about merging deposits and candidates? I think they have overlapped lifetimes.
sgkim126 commentedon May 20, 2019
@foriequal0 LGTM
sgkim126 commentedon May 21, 2019
@foriequal0 How about storing the validators sets in the states?
It would simplify the restoring logic.
foriequal0 commentedon May 22, 2019
I've applied the diff. Data saved in COL_EXTRA like the validator set and the validator order is not stored anymore. It should be recovered from the last term end.