EOSIO / eosio.contracts

Smart contracts that provide some of the basic functions of the EOSIO blockchain
https://eosio.github.io/eosio.contracts/latest
MIT License
326 stars 415 forks source link

General stake-weighted voting functionality #44

Closed wanderingbort closed 3 years ago

wanderingbort commented 6 years ago

Relayed for @jchung00 from EOSIO/eos#5172

Currently, it is difficult to implement stake-weighted voting on any contract. It is possible to find staked amount for each account on the voters table, but it is not possible to track stake/unstake changes within a contract. Therefore, it requires a database off chain that actively monitors delegatebw/undelegatebw actions in order to implement this.

A more general way to allow stake-weight voting to occur fully on chain would be beneficial for some contracts/systems that need it. This includes the Referendum contract and Worker Proposal system. There may also be some other community tools and dApps that need the functionality as well.

A potential solution would be have the system contract send inline-actions for delegatebw/undelegatebw actions, and implementing a general purpose stake based voting scheme in the system contract. Another idea that Greg/Bart mentioned was to add the ability for any contract to "hook" actions in any other contract in the future. For example, a contract that needs stake-weighted voting would "register" with the system contract that it wants an inline action scheduled when someone calls the delegatebw and undelegatebw actions. This solution would allow contracts to build off on existing system contract actions. In order to prevent spam and potential bottleneck, there must be a limit to who can register these "hooks". Therefore, the ability to register could be implemented through an action that requires the permission of eosio.prods, so that only community verified contracts can register the hooks/callback actions.

deckb commented 3 years ago

We are doing some clean up and are closing old issues. Please reopen in the new system repo if that is desired.