Host whitelist blacklist
NEW FEATURE
Description of Feature
Add white and black list to hostdb so renter can have more control over the hosts it uses.
Description of Work Flow
The white and black lists are maps that belong to the hostdb, they are accompanied by two boolean fields useBlackList
and useWhiteList
. The renter can enable either mode by submitting a call to the api endpoint /hostdb/listmode
with a list of host pubkeys and true
for blacklist mode or false
for whitelist mode. To disable, the renter just needs to submit an empty list to the same end point with the appropriate true
or false
. When either mode is enabled, the hostdb will enforce the mode by filtering the hosts that are returned from the hosttree. This allows the hosttree to continue to be maintained with all the hosts on the network, so when a mode is disabled the hostdb doesn't need to re-scan the blockchain to find all the hosts again. Additionally when either mode is enabled, any active contracts with unwanted hosts are cancelled. There are no updates to threadedContractMaintenace
as even if something goes wrong with cancelling the contracts when a mode is enabled, any contract with an unwanted host will not be renewed nor will a new contract be created with an unwanted host due to the filtering of the hosttree.
Testing Added
Siatest added that tests:
- Enable Blacklist: confirm contracts form as expected, confirm hostdb is filtered as expected
- Disable Blacklist: confirm contracts are reformed with blacklisted hosts
- Try to enable whitelist without enough hosts
- Enable Whitelist: confirm contracts form as expected, confirm hostdb is filtered as expected
- Disable Whitelist: confirm contracts are reformed with non whitelisted hosts
Modules and Packages Impacted
renter, hostdb, api
Closes #3216 (closed)