81 Commits

Author SHA1 Message Date
jholdstock
1d2340d61c Update Decred dependencies for 2.1.0 2025-11-26 11:39:57 +00:00
jholdstock
30dcf49c62 vote-validator: Simplify f.WriteString
fmt.Fprintf acheives the same thing in a single func.
2025-04-15 09:34:37 +01:00
jholdstock
0d7b33d9bd multi: Use go 1.22 language features. 2025-02-28 09:04:56 +00:00
jholdstock
a80e40d650 v3tool: Continue if a ticket already has paid fee.
v3tool will now attempt to register all tickets with the VSP rather
than immediately exiting if one of the tickets already has a paid fee.
2024-07-17 10:20:35 +01:00
jholdstock
906ffc9e88 multi: Consider DCP0012 in VSP fee calculations.
Upgrade the dcrwallet dependency to pick up the new version of
txrules.StakePoolTicketFee which considers the status of DCP0012 in its
fee calculation.
2024-06-30 09:22:21 +01:00
jholdstock
fef56a24a0 vote-validator: Use stdlib built-in "POST" const. 2024-06-30 09:16:31 +01:00
jholdstock
cab4058710 vspadmin: Add retirexpub command.
The new command opens an existing vspd database and replaces the
currently used xpub with a new one.
2024-06-27 09:20:32 +01:00
jholdstock
1fa81d3697 vspadmin: Reject private keys in fee xpub config.
The provided key should always be a public key, enforcing this in
software provides an extra safety net for users.
2024-06-19 09:56:29 +01:00
jholdstock
4e5fec8f3b vspadmin: Write default config file.
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.
2024-06-19 09:35:41 +01:00
jholdstock
997205ed95 vspadmin: New binary to create empty databases.
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.
2024-06-19 09:35:41 +01:00
jholdstock
1a2b02466c vspd: Wrap RPC connection details in a struct.
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.
2024-05-30 08:41:10 +01:00
jholdstock
086143fed2 vspd: Move config to internal package.
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.
2024-05-30 08:41:10 +01:00
jholdstock
10457e6110 vspd: Accessors for derived config values.
This enables the derived config values, which are not exported, to still
be accessed after config.go is moved to the internal vspd package.
2024-05-30 08:41:10 +01:00
jholdstock
ecf2baa193 Begin module dev cycles.
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.
2024-05-29 11:02:50 +01:00
jholdstock
6e558fb283 vspd: Decouple config loading & log initialization
Loading config and preparing loggers are two separate concepts which
should be handled individually. Nesting one inside the other makes
little sense and complicates reusing the code.
2024-05-23 08:39:24 +01:00
jholdstock
64ad28e19b database: Remove log param from CreateNew.
This logger did not write any useful information and all errors
generated by the func are already returned to the caller for logging.
2024-05-23 08:39:24 +01:00
jholdstock
17f993ae83 config: Initialize default config struct directly.
There is no need to declare a dozen different "default..." vars only to
immediately insert them into a default config struct when the struct
itself could just be initialized with the default values instead.
2024-05-23 08:28:42 +01:00
jholdstock
8b6b2e4fef config: Deprecate --configfile.
This removes the --configfile option from vspd. It introduced quite a
few weird edge cases (and a fair bit of code to deal with them) but
afaik nobody actually used it. Note that the --homedir option stays, so
it is still possible to run vspd with config in a non-default location
if required.
2024-05-21 08:44:59 +01:00
jholdstock
2bd340ba08 multi: Explicitly handle help requests.
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`.
2024-05-18 08:42:06 +01:00
jholdstock
ea6f5e8d7e config: Introduce NetworkFromName.
This moves the mapping logic to a more obvious home and enables it to be
reused later.
2024-05-16 08:23:24 +01:00
jholdstock
17e97384e5 v3tool: Remove unnecessary err check.
err has already been checked and is known to be nil at this point.
2024-05-14 07:27:56 +01:00
jholdstock
1e66b6ff59 Downgrade dcrwallet dep to v3.
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.
2023-11-08 09:01:36 +00:00
jholdstock
1e6b379864 v3tool: Remove hard-coded agenda ID.
Getting an agenda ID dynamically so that this doesnt need to be manually
updated for future vote versions.
2023-09-26 10:21:38 +01:00
jholdstock
e1885bb7cb multi: Rename shutdownWg to wg.
The more verbose name was helpful in the past when some code was
handling more than one waitgroup, however that is no longer the case due
to refactoring so reverting to the more concise name makes sense.
2023-09-26 10:21:38 +01:00
jholdstock
fb1f250a74 vspd: Create shutdown context earlier.
Create the shutdown context earlier so process begins handling shutdown
signals earlier. Specifically, the context should be created before
creating any resources which need a graceful shutdown such as the
database. This is important because without explicit signal handling the
process will terminate immediately upon receiving a signal without
running deferred tasks.
2023-09-26 10:21:38 +01:00
Jamie Holdstock
81784accb6
Update main module dependencies 2023-09-26 09:23:32 +01:00
jholdstock
d1eddafb52 v3tool: Use shutdown context.
Using the shutdown context provided by the internal signal package means
v3tool can exit cleanly if shutdown is requested by the user.
2023-09-19 08:33:42 +01:00
jholdstock
9660de7d9f vote-validator: Use shutdown context.
Using the shutdown context provided by the internal signal package means
vote-validator can exit cleanly if shutdown is requested by the user.
2023-09-19 08:33:42 +01:00
jholdstock
935dcaece2 multi: Move signal to internal package. 2023-09-19 08:33:42 +01:00
jholdstock
2faaa8b32b vspd: Support SIGTERM on Win and all unix variants
Go 1.14 added runtime support for handling the windows CTRL_CLOSE_EVENT,
CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT events by adding a definition
for syscall.SIGTERM to windows and converting the events to that signal.
It also added definitions for other common signals, including SIGHUP,
and treats them as NOOPs on windows.

Consequently, this modifies the logic that deals with conditionally
handling SIGTERM and SIGHUP to handle them for windows as well as all
unix-like operating systems, including newer ones that are supported by
Go since the code was originally written.

Although the additional signals could probably just be added
unconditionally without too much issue now due to the runtime adding
stubs to all operating systems the project officially supports, it is
safer to be explicit when dealing with syscall definitions since there
is no guarantee that they will exist for newly-added operating systems.
2023-09-19 08:33:42 +01:00
jholdstock
546a87fd5b vspd: Remove shutdownRequestChannel.
The removal of the requestShutdown function in a previous commit means
that the shutdownRequestChannel is no longer needed, so this commit
removes it.
2023-09-19 08:33:42 +01:00
jholdstock
d10e7daf74 vspd: Ensure backup loop runs forever.
Fixing a bug where the backup loop was not a loop - it was only running
one time.
2023-09-18 17:55:29 +01:00
jholdstock
74729c6cc9 multi: Consider DCP0012 in VSP fee calculations.
Upgrade the dcrwallet dependency to pick up the new version of
txrules.StakePoolTicketFee which considers the status of DCP0012 in its
fee calculation.
2023-09-16 08:36:41 +01:00
jholdstock
ee4a440534 multi: Move vspd to internal package. 2023-09-16 08:29:17 +01:00
jholdstock
5bce5e6cfc vspd: Trigger database backups in main run func. 2023-09-16 08:29:17 +01:00
jholdstock
6c245b8418 vspd: Separate vspd and webapi.
The vspd Run func is now blocking and returns when its provided context
is cancelled. This means it is invoked/canceled in the same way as the
webapi Run func.

webapi is now created in the main run func rather than within vspd,
further decoupling these components.
2023-09-16 08:29:17 +01:00
jholdstock
ba3c7bf6d9 vspd: Create essential resources in main run func.
Creating the essential DB/RPC resources which are required for both
webapi and vspd in the main func allows the two components to be
decoupled.
2023-09-16 08:29:17 +01:00
jholdstock
f881179024 webapi: Make Run func blocking.
This updates the Run func to make it blocking. When the provided context
is canceled the server is cleanly shut down and the func returns.
2023-09-16 07:54:24 +01:00
jholdstock
0742e0ff1a webapi: Split Start func into New and Run funcs.
Separating the single func grants the calling code greater control over
the webapi lifecycle.
2023-09-16 07:54:24 +01:00
jholdstock
e26c8db199 vspd: Copy VSP fee validation func from wallet.
This is such a trivial func that there is no need to import it from
wallet, it can just be copied into this project.
2023-09-14 20:42:22 +01:00
jholdstock
d1766c362e webapi: Add Listen to webapi Config.
No need for this value to be passed in separately, it can be passed in
the same as every other config value.
2023-09-14 20:42:12 +01:00
jholdstock
a33bcbcbfd multi: Reuse CurrentVoteVersion helper.
Moving CurrentVoteVersion to the config package allows it to be reused
in vote-validator.
2023-09-14 20:39:49 +01:00
jholdstock
d5d1c3239c multi: Move netparams to internal.
A new internal package named config contains all of the hard-coded, network specific values used by vspd.
2023-09-14 20:39:49 +01:00
jholdstock
17fe1d7db1 vspd: Americanize "cancelled".
Consistent with the go stdlib (e.g. context.Canceled).
2023-09-13 09:10:10 +01:00
jholdstock
8038a0ea46 vspd: Move start/stop logging to main func.
This ensures that the startup/shutdown messages are always the
first/last thing to be logged.
2023-09-13 09:10:10 +01:00
jholdstock
e38032ba2f vspd: Run deferred tasks on os.Exit.
Any tasks deferred in the main func will not execute if os.Exit is
called. Moving application logic down into a new func which is called by
main works around this limitation.
2023-09-13 09:10:10 +01:00
jholdstock
b5ffecd280 version: Don't export funcs/vars unnecessarily. 2023-09-13 09:03:05 +01:00
jholdstock
3d4fb6ab99 version: Move package to internal. 2023-09-13 09:03:05 +01:00
jholdstock
7ad309c9aa webapi: Move package to internal. 2023-09-13 09:03:05 +01:00
jholdstock
841c8ba115 vspd: Enable checkWalletConsistency interrupting.
Add a Context parameter to checkWalletConsistency so it can be canceled
when a shutdown is requested.
2023-09-08 09:59:00 +01:00