voter

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 17 Imported by: 0

README

fio-bp-vote

This is an automated voting tool that ranks producers based upon criteria (that can be validated on-chain) in the BP Code of Conduct. The goal is to reward producers that actively contribute to keeping the chain healthy, therefore actions like participating in proposals for setcode, and performing fee maintenance are strongly favored. Sending requests that should be seen frequently are also rewarded.

Current ranks for mainnet can be viewed here

It allows setting the number of producers to vote for, how often to recalculate votes, allows using a linked-auth key (highly recommended!), and can restrict to only include a list of allowed producers. It will check every minute for producers missing (full) rounds, and retracts their votes. It will not vote for them again for three times the vote calculation frequency (3 days by default.)

Options

  -a string
        actor
  -address string
        fio address
  -allowed string
        plaintext file of producers eligible for votes: FIO address, 1 per line
  -dry-run
        don't push transactions, only print what would have been done.
  -h int
        how often (hours) to run (default 24)
  -k string
        wif key
  -n int
        how many (max) producers to vote for (default 30)
  -p string
        permission, if not using 'active'
  -u string
        url for connect
  -v
        verbose logging

Scoring Criteria:

participation in msig (propose, approve, exec)              + 10 points each, last 30 days
fee votes (bundlevote, setfeevote, setfeemult)              + 1 points each, last 30 days
maintenance (bpclaim, tpidclaim, burnexpired, computefees)  + 1 point each, last 24 hours

url in producers table is reachable            + 1 point
url has a bp.json or chain json                + 1 point
permissive CORS for bp.json                    + 1 point

Penalties:
----------

average CPU for transactions, last 48 hours    - neg 3 points, per each 1ms over 5ms avg
have not performed bpclaim in last 30 days     - neg 100 points
does not have any existing votes               - neg 200 points
missed round                                   - will not get a vote for next 3 cycles, triggers immediate re-calculation

The CPU penalty is admittedly not an objective measurement, but does seem to be effective as slower nodes tend to take significantly longer to process a transaction, often as much as 10x longer for an underpowered node.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Url       string
	Perm      string
	Actor     string
	Key       string
	Allowed   string
	Address   string
	Frequency int
	NumVotes  int
	Dry       bool
	V         bool
	Vmux      sync.Mutex

	LastVote string
)
View Source
var (
	MissedAfter time.Time
	Missed      = make(map[string]time.Time) // holds those who missed blocks, expires at 3*Frequency
	MissedBlk   = 720                        // how many blocks since last producing that gets you kicked ....
)

tracks missed blocks

Functions

func CpuRanking

func CpuRanking(api *fio.API) (map[string]int, error)

CpuRanking penalizes for high numbers, averages over 4k get negative score, increasing by 1 per 1,000µs

func FindMisses

func FindMisses(cpuRank map[string]int, api *fio.API) error

func RankProducers

func RankProducers(eligible []string, cpuRank map[string]int, api *fio.API) ([]string, error)

func Vote

func Vote(cpuRank map[string]int, api *fio.API) error

Types

type BpRank

type BpRank struct {
	Address fio.Address     `json:"address"`
	Score   int             `json:"score"`
	Account eos.AccountName `json:"account"`

	FeeVote   int `json:"fee_vote_30d"`
	Compute   int `json:"compute"`
	Msig      int `json:"msig_30d"`
	BpClaim   int `json:"bpclaim_1d"`
	TpidClaim int `json:"tpidclaim_1d"`
	Burn      int `json:"burnexpired_1d"`
	CpuScore  int `json:"cpu_score"`

	// TODO: even more info
	//Monitor      bool `json:"monitor"`
	//ApiAvail     bool `json:"api_avail"`
	//ApiTls       bool `json:"api_tls"`
	//P2pAvail     bool `json:"p2p_avail"`
	//NetApi       bool `json:"net_api"`
	//ProdApi      bool `json:"prod_api"`
	//MissedBlocks int  `json:"missed_blocks"`
	MissingExcluded bool `json:"missing_excluded"`

	DiffSignKey       bool `json:"diff_sign_key"`
	BpJson            bool `json:"bp_json"`
	BpJsonCors        bool `json:"bp_json_cors"`
	RegValidUrl       bool `json:"valid_url"`
	UsingLinkedOrMsig bool `json:"using_linked_auth_or_msig"`
	HasClaimed        bool `json:"has_claimed_30d"`

	Svg  string `json:"svg"`
	Time string `json:"time"`
	// contains filtered or unexported fields
}

type ProducerCompact

type ProducerCompact struct {
	FioAddress        string       `json:"fio_address"`
	TotalVotes        string       `json:"total_votes"`
	Url               string       `json:"url"`
	LastClaimTime     eos.JSONTime `json:"last_claim_time"`
	LastBpClaim       int64        `json:"last_bpclaim"`
	ProducerPublicKey string       `json:"producer_public_key"`
}

ProducerCompact trims the response to only what we need.

func GetProducerCompact

func GetProducerCompact(acc eos.AccountName, api *fio.API) (addr string, pc *ProducerCompact, err error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL