返回介绍

Validator Contracts

发布于 2023-06-28 21:14:12 字数 4760 浏览 0 评论 0 收藏 0

Majority List

This contract starts with an initial set of validators supporting each other. Validator can add or remove support given to as many addresses as they want. If an address is supported by more than a half of validators then it becomes a validator, similarly if support for a validator falls below a half then they are removed. Support can not be added once MAX_VALIDATORS is reached. Validators are automatically reported if they misbehave and support is removed after MAX_INACTIVITY period.

The following is the user facing ABI that can be used to interact with the contract:

[{"constant":true,"inputs":[{"name":"validator","type":"address"}],"name":"highSupport","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"validatorsList","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"validator","type":"address"}],"name":"removeValidator","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"validator","type":"address"}],"name":"addValidator","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"validator","type":"address"}],"name":"getRepeatedBenign","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"validator","type":"address"}],"name":"getSupported","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"MAX_VALIDATORS","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"reporter","type":"address"},{"name":"validator","type":"address"}],"name":"firstBenignReported","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"validator","type":"address"}],"name":"getSupport","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"validator","type":"address"}],"name":"addSupport","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"validator","type":"address"}],"name":"absolveFirstBenign","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"MAX_INACTIVITY","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"validator","type":"address"},{"name":"blockNumber","type":"uint256"}],"name":"reportBenign","outputs":[],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"parent_hash","type":"bytes32"},{"indexed":true,"name":"nonce","type":"uint256"},{"indexed":false,"name":"new_set","type":"address[]"}],"name":"ValidatorsChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"reporter","type":"address"},{"indexed":true,"name":"reported","type":"address"},{"indexed":true,"name":"malicious","type":"bool"}],"name":"Report","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"supporter","type":"address"},{"indexed":true,"name":"supported","type":"address"},{"indexed":true,"name":"added","type":"bool"}],"name":"Support","type":"event"}]

Inspecting the state

  • getValidators method lists the current validators
  • getSupport returns the number of validators what support a given validator
  • getSupported lists all addresses supported by the given validator

Adding support

To support an address to become a validator execute the addSupport with that address.

Removing support

Removing support should be done by executing reportBenign twice, second time being after MAX_INACTIVITY seconds.

Absolving a validator

After executing reportBenign a validator may change their mind. They should then execute absolveFirstBenign to forget about it.

Inactivity

If a validator misses a block nodes will automatically execute reportBenign, thus if inactivity exceeds or repeats after MAX_INACTIVITY period, support will be removed.

Malicious behaviour

If a validator runs two signing nodes or modifies the code to attempt to create forks other nodes will automatically remove support for them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文