This repository has been archived by the owner on Mar 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Add state representation #32
Merged
Merged
Changes from 2 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
a453c4d
Add basic state representation.
adlerjohn 62420a9
Fix typo is size of validator voting power.
adlerjohn cf6e484
Update specs/data_structures.md
adlerjohn a1340ff
Add nonce field to accounts.
adlerjohn a2adee4
First draft refactor: validators and accounts in a single tree.
adlerjohn 6201f4c
Add consensus constants for unbonding duration and maximum active val…
adlerjohn 2b14d8d
Add validator and delegation structs to accounts.
adlerjohn 9ce5d6c
Add additional validator and delegation fields.
adlerjohn 06f6436
Add explanation for validator status.
adlerjohn 05b2d47
Add explication for delegation status.
adlerjohn 00d4675
Add slashing fields to validator.
adlerjohn 5a60665
Clean up.
adlerjohn 2df269d
Add accumulation of voting power and rewards to validators and delega…
adlerjohn 4cf479a
Reduce the precision of voting power to whole coins (i.e. drop 9 zero…
adlerjohn 411925c
Remove todo.
adlerjohn 7f31112
Add rules for calculating rewards and penalties for delegations and v…
adlerjohn 34d9ddc
Clean up.
adlerjohn 8339f86
Add rule to update accumulated voting power also when validator begin…
adlerjohn 61cbe55
Clarify that accumulated voting power is in whole coins.
adlerjohn f7bc92b
Add commission calculations.
adlerjohn 0828bf3
Fix tables.
adlerjohn 3f320e0
Fix commissions.
adlerjohn d87ef53
Rename calculating rewards and penalties to distributing.
adlerjohn 08dfbc5
Clean up.
adlerjohn 313388e
Migrate rationale for reward distribution to dedicated document.
adlerjohn ecda995
Fix commission calculation for validator.
adlerjohn 4fd51b7
Remove some rationale from consensus document for reward distribution.
adlerjohn fa9307b
Add preamble to reward distribution doc, clearn up.
adlerjohn e1d624c
Clean up.
adlerjohn 39bc623
Revamp reward distribution rationale.
adlerjohn 6bba8c6
Fix state data structures for reward distribution.
adlerjohn 6e036ad
Remove redundant entry from validator.
adlerjohn 747b594
Remove other redundant entry from validator.
adlerjohn 62f759c
Fix consensus rules for distributing rewards.
adlerjohn 09f95d2
Cleanup.
adlerjohn 5449c59
Update specs/consensus.md
adlerjohn e8cc2d3
Simplify naming of accounts tree.
adlerjohn e4005c8
Clean up.
adlerjohn 8785e68
Clean up informal language.
adlerjohn 70ac923
Refactor consensus rules for validators and delegations to use code s…
adlerjohn f1cba75
Refactor state tree to use a single unified tree with distinct subtrees.
adlerjohn a9d5149
Fix typo.
adlerjohn 4fbff8a
Remove redundant state root definition.
adlerjohn 4a50807
Remove redundant validator flag in accounts.
adlerjohn a8c17a7
Add protobuf definitions for state elements.
adlerjohn 73de678
Add another subtree for inactive validators.
adlerjohn b4db7e3
Clean up.
adlerjohn 2c4e44c
Fix typo.
adlerjohn 4d87996
Move the active validator count to the active validators subtree.
adlerjohn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't accounts delegate to several validators? Also maybe:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because that would add complexity (you'd have to hold a variable number of validators and the number of coins each of them is delegated), and if someone wants to delegate their coins to two validators they can just...split up their coins into two accounts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scheme (which isn't obvious from the data structures, but will be written in the consensus rules) is: "all the coins in an account are either delegated or not; if they're delegated they must be delegated to a single validator."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a user (holding coins) and a UX perspective, splitting up coins into separate accounts whenever you want to delegate to more than one validator also adds complexity, but one the human (not on the software).
Note that in the few delegations based PoS systems that launched, you can usually delegate to one or more validators. This is also true in Cosmos / the cosmos-sdk. Most users I know delegate to several validators to keep the network decentralized (and to hedge their risks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I don't see why this can't be abstracted away at the application layer, rather than having to be pushed to the user layer. Moving a portion of your coins to a new address then delegating them (as well as the reverse) can be done just as seamlessly in a wallet---one button press. Users don't even have to know it's happening! It's basically UTXO management; most Bitcoin wallets don't present to lay users each individual UTXO, just their total balance.
Allowing an arbitrary number of delegations per account means fraud proofs are more complex and expensive.
That being said, given that we're using the accounts data model for now, one downside of essentially emulating UTXOs for delegating stake is that the nonce of empty accounts still needs to be kept around forever (which reminds me, a nonce field needs to be added).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that it would actually be more intuitive from a UX perspective to require users to split their coins into different accounts to delegate to different validators. It's the logical purpose of accounts - the same way you might have multiple savings accounts for different purposes.
It seems more complicated from a UX perspective to have users enter each validator they want to delegate to and the amount in some kind of table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But here you'd have multiple accounts for one purpose: namely delegating to validators. Having a different account per validator would be like opening a broker account per same type of investment (or one "account" per stock or bond you buy).