**Warning: This commit contains a database upgrade.**
In order to add future support for retiring xpub keys, the database is
upgraded such that the keys are now stored in a dedicated bucket which
can hold multiple values rather than storing a single key as individual
values in the root bucket.
A new ID field is added to distinguish between keys. This ID is added to
every ticket record in the database in order to track which pubkey was
used for each ticket.
A new field named "Retired" has also been added to pubkeys. It is a unix
timestamp representing the moment the key was retired, or zero for the
currently active key.
A new command in vspadmin writes the default config file for a new vspd
deployment. The behaviour is removed from vspd and documentation has
been updated to reflect the change.
vspadmin is a new binary which implements one-off admin tasks which are
necessarily interactive and thus do not fit neatly into the long-lived
vspd binary.
The first behaviour added to vspadmin is the ability to create a new
vspd database. This behaviour is removed from vspd with the associated
config option deprecated. Documentation and scripts updated to reflect
the change.
Fee xpub key and last used address index are now wrapped into a struct,
with both fields being set and retrieved together rather than
individually.
The underlying format for storing these values in the database does not
change. The only change is the interface between the database code and
the caller.
Returning a single struct which contains multiple named fields reduces
the chance of a mistake in the calling code, as compared to returning
multiple unnamed values which are all of the same type.
This enables the config to be reused in multiple binaries - eg. the
upcoming vsp admin binary which will be responsible for writing a
default config file for new vspd deployments.
Upcoming changes constitute breaking public API changes to both the
client and types modules, therefore this bumps the version numbers of
both modules and adds local replacements to go.mod files such that the
new versions can be used before they are publicly tagged.
Checking for --help as an explicit step before parsing any other configs
makes the code more intuitive by removing a convoluted bit of error
handling, which happened to be unnecessarily duplicated in three places.
Moving it to a function in the internal package makes it reusable by
multiple binaries.
This also enables the IgnoreUnknown option to be used whilst parsing for
help, which ensures the presence of --help will always result in the
help message being printed. This fixes a minor inconsistency where the
help message would be printed if the flag was placed before an invalid
config, but placing it after would cause an invalid config error to be
written instead. For example, `vspd --help --fakeflag` vs `vspd
--fakeflag --help`.
This downgrade changes StakePoolTicketFee back to the version which does
not consider DCP-0012 activation.
This resolves an issue where Decrediton sometimes fails to pay VSP fees,
caused by Decrediton and vspd independently calculating the fee amount
using different versions of the algorithm.
Releasing the new algorithm will need to be more carefully coordinated,
potentially requiring both client and server sides to be updated in
sync.
If broadcasting parent transaction of a ticket fails because it
references unknown outputs, there is a good chance that waiting a few
seconds will resolve the issue because the ancestor transactions will
propagate through the network and reach the mempool of the local dcrd
instance.
A new tab on the admin page displays a list of all tickets which were
registered with the VSP but missed their votes. Clicking on the ticket
hash redirects to the Ticket Search tab with the details of the missed
ticket displayed.
This splits the code from vspd.go into various other files which broadly
represent the functional areas of vspd - the main update function,
database intgrity checks and voting wallet consistency checks.
Code is just moved without any modifications.
The name blockConnected is not very accurate as this function is also
called when vspd is initializing. It doesnt depend on a block having
been connected at all, it can be called at any time.
Give the debug banner a unique look by changing its class to "danger",
and centering and bolding the text. This helps it to be more noticable
when displayed near other banners.
Rather than immediately returning an error if the cache is not
initialized, attempt to initialize it first. Without this change there
is only an attempt to initialize the cache once per minute.
A new middleware aborts any requests which require the data cache if the
cache is not yet initialized. An explicit error is returned so the admin
will be immediately aware what has gone wrong.
Previously, webpages were rendered and JSON responses were sent with
zero values, and with no indication of anything being wrong. This was
sometimes difficult to notice, and even when noticed the cause was not
immediately apparent.
Upgrade the dcrwallet dependency to pick up the new version of
txrules.StakePoolTicketFee which considers the status of DCP0012 in its
fee calculation.
Don't log errors returned by server.Shutdown. They are exceedingly
unlikely, and there is nothing which can be done about them.
Moving the "Listening on..." log closer to where the server is actually
started reduces the chance of confusion. Also, logging the parsed
listener.Addr() string instead of the provided config string provides
extra debugging detail.
The server will shutdown cleanly even if the passed context is already
canceled, so there is no need to pass a new context and blindly guess at
how long the server may need to stop.
Exporting this struct is a step towards breaking up the Start func into
a New func and Run func, enabling calling code to use:
api := webapi.New()
api.Run()
WebAPI is a more suitable name than server because it matches the
package name, and also it helps to distinguish WebAPI from the HTTP
server it uses internally (ie. webapi.server rather than server.server).
It's generally good practice to first create everything that can fail
and then create the final instance at once with the results versus doing
it piecemeal.
Piecemeal creation is typically more error prone and, while not a huge
concern here, it also ends up needlessly creating objects that are just
thrown away in the event of a later error.
Storing references to the database/dcrd/dcrwallet clients inside the
cache struct means they don't need to be passed in every time the cache
is updated.