decred / vspd

A Voting Service Provider (VSP) for the Decred network.
ISC License
19 stars 20 forks source link

Implement tspend policy operations APIs #234

Open matheusd opened 3 years ago

matheusd commented 3 years ago

Policy choice for tspends can be set on dcrwallet for both a specific pi key (that is, approving or disapproving all tspends signed by some given key) or by individual tspend hash.

This needs to be exposed so that stakeholders can select their preference for when their vote is cast.

At a minimum, users need to be able to set and retrieve the vote choices for a given ticket.

jholdstock commented 3 years ago

Add optional params to /payFee request

The client is currently setting their consensus vote choices when a ticket is initially registered with the /payFee request. We should add new, optional params to also set tspendPolicy and piKeyPolicy. eg.

...
"tspendPolicy": { "first_tspend_hash": "yes", "second_tspend_hash": "no" },
"piKeyPolicy": { "first_pi_key": "yes", "second_pi_key": "no" },
...

New endpoints for updating tspendPolicy/piKeyPolicy

Using the same request encoding specified above, and the existing mechanisms for ticket authentication and storing request history for accountability.

Additional thoughts

davecgh commented 3 years ago

The mostly seems fine, but I don't see a way to disallow a specific pi key (for example, if it gets compromised, etc). Simply not specifying one would result in an abstain as opposed to explicitly voting no.

jholdstock commented 3 years ago

Typo - I fixed the piKeyPolicy example above

jholdstock commented 3 years ago

I've started implementing this and rather than creating new endpoints for /setspendpolicy and /settreasurypolicy, I think it makes more sense to add new optional fields to the existing /setvotechoices endpoint.

The name setvotechoices is already generic enough to cover both consensus voting and treasury spend voting. Internally to vspd, it will ease the process of recording vote choice changes. From a wider perspective, it will reduce the amount of network calls required to update choices, which in turn may reduce the amount of times accounts need to be unlocked in dcrwallet to sign requests.

jholdstock commented 3 years ago

Still waiting for a way to bulk retrieve tspend/treasury policies from dcrwallet for the purpose of consistency checking.

Also identified that tspend and treasury policies could be a DoS vector for VSP servers. If vspd accepts any hash and/or any treasury key, a malicious user could spam loads of them and fill the vspd/wallet DBs.

jholdstock commented 1 year ago

Still waiting for a way to bulk retrieve tspend/treasury policies from dcrwallet for the purpose of consistency checking.

This is still outstanding, the last thing required before this issue is closed.

Also identified that tspend and treasury policies could be a DoS vector for VSP servers. If vspd accepts any hash and/or any treasury key, a malicious user could spam loads of them and fill the vspd/wallet DBs.

This was mitigated by subjecting tspend/treasury vote changes to the same limit as agenda vote changes. The database will only keep a record of the 10 most recent changes for each ticket.