Commit Graph

5649 Commits

Author SHA1 Message Date
Ryan Staudt
0bf463d7d5 multi: Flush block DB before UTXO DB.
This adds a flushBlockDB function to the UTXO cache.  The flushBlockDB
function is used to flush the block database to disk prior to flushing
the UTXO cache to the UTXO database.

This ensures that the block database is always at least as far along as
the UTXO database which keeps the UTXO database in a recoverable state
in the event of an unclean shutdown.
2021-05-13 22:43:30 -05:00
Ryan Staudt
bdccd3e3f7 database: Add Flush to DB interface.
This adds a Flush method to the DB interface so that users of the DB
type can flush the underlying database to disk as needed.

The immediate use case for this is to allow for flushing dependencies.
For example, the block database always needs to be flushed to disk prior
to the UTXO database being flushed to disk to ensure that the UTXO
database remains in a recoverable state in the event of an unclean
shutdown.
2021-05-13 22:43:30 -05:00
Dave Collins
110bd6e15d
rpcserver: Remove unused help entry.
This removes the gettxoutresult-version key from the RPC server help map
since the field no longer exists in the actual output and is therefore
no longer used.
2021-05-13 18:22:53 -05:00
JoeGruff
f993444a0c docs: Add scriptpubkey json returns. 2021-05-13 16:00:22 -05:00
JoeGruff
98a74c6084 rpcserver: Add script version to gettxout. 2021-05-13 16:00:22 -05:00
Dave Collins
4e0be8d2fb
txscript: Split signing code to sign subpackage.
The current code for handling signing standard scripts resides in
txscript and depends on parsing and creating standard scripts.  This
poses a problem for future work which intends to split the standard
script handling from the consensus critical code since that code will
also need to depend on txscript and therefore would result in a circular
dependency.

In order to pave the way for splitting the standard script handling
without running into the aforementioned issue, this moves all of the
signing code in the txscript package to a new subpackage named sign.

As an aside, the signing code really never fit very well in the txscript
package anyway and it only exists there because it was not possible to
parse scripts outside of the package back when the original code was
implemented.  However, that limitation no longer exists.

It should also be noted that this only does the minimum work necessary
to move the code and does not update it otherwise since future work
plans to replace it with a much more robust architecture that properly
handles things such as different script versions and non-standard
scripts which the current code does not handle.
2021-05-07 13:19:00 -05:00
Josh Rickmar
83fd5109a4 contrib: Update OpenBSD rc script for 6.9 features.
OpenBSD 6.9 includes a new daemon_logger variable which may be set to
automatically set the syslog facility that the process will write to.
This lets us simplify our example service by avoiding the need to
redefine the rc_start function.

While here, update some of the default flags to more closely match
what I now recommend.  /var is too small for block data on many
installations, so it is better to write all of the application data to
the /home partition instead.  This also fixes the comment for how to
enable the service, since just defining the flags is not sufficient
for this.
2021-05-05 12:43:55 -05:00
Josh Rickmar
c9099b6488 main: Handle SIGHUP with clean shutdown.
When the SIGHUP signal is received, the process should perform
graceful shut down rather than dying from the unhandled signal.

For clarity, the signals which will cause shutdown have been moved to
a new filename so it does not remain specific to only SIGTERM
handling.
2021-05-05 12:29:05 -05:00
Josh Rickmar
44600dd678 rpcserver: Allow interface names for dial addresses
This allows RPCs which take hostnames as parameters (such as the
'node' method) to interpret the host part as an interface name, and
use the first IP address associated with the interface.  This is done
for consistency with how interface names may be used in the dcrd
application config.
2021-04-28 14:57:48 -05:00
Josh Rickmar
bbecbe9e7e config: Allow interface names for listener addresses
For config options which specify listen addresses (such as --listen
and --rpclisten), all addresses associated with the interface will be
listened on.  For config options which specify dialed addresses (such
as --addpeer, --connect, --proxy, and --onion), only the first address
associated with the interface is included.
2021-04-28 14:57:48 -05:00
Ryan Staudt
73d1b5f7de multi: Migrate to UTXO database.
This migrates the UTXO set and state from the block database to the new
UTXO database.  The benefit of doing this is that it will allow the
reading and writing to the UTXO set in the database to be optimized
specifically for use with the UTXO set.

An overview of the changes is as follows:

- Introduce upgrade code to migrate UTXO data from the block database to
  the new UTXO database
- Update all references to use the UTXO database rather than the block
  database where appropriate
2021-04-28 10:27:55 -05:00
Ryan Staudt
6ce69b0992 blockchain: Decouple stxo and utxo migrations.
This decouples the overall block database version and migrations from
the spend journal and utxo set versions and migrations.

This provides a couple of benefits.  Firstly, the migration to version 3 of the
spend journal and utxo set currently require the block index to be loaded.  In
the future this could be handled by reindexing, once that is introduced, but
until then this decoupling allows for new block database versions and migrations
to be run prior to the block index being loaded.

Secondly, this is a step toward removing the dependency that the utxo set and
spend journal have on the block database and index.

This is part of moving the UTXO set and state to a separate database.
2021-04-28 10:27:55 -05:00
Ryan Staudt
99259dc523 multi: Introduce UTXO database.
This introduces a separate UTXO database that holds the UTXO database
info.  In a subsequent commit it will additionally hold the UTXO set and
state.

An overview of the changes is as follows:

- Introduce LoadUtxoDB to load (or create when needed) the new UTXO
  database on startup
- Add utxoDb and utxoDbInfo to BlockChain to hold the new UTXO database
- Initialize the UTXO database info in the UTXO database on startup
- Populate utxoDb for mock chains in tests

This is part of moving the UTXO set and state to a separate database.
2021-04-28 10:27:55 -05:00
Ryan Staudt
105f0bad80 blockchain: Add utxoDatabaseInfo.
The adds utxoDatabaseInfo which tracks the version, compression version,
utxo set version, and creation time of the UTXO database.  The UTXO
database will be created as a separate database in a subsequent commit.

This is part of moving the UTXO set and state to a separate database.
2021-04-28 10:27:55 -05:00
Ryan Staudt
c7315b6bf6 ipc: Fix lifetimeEvent comments.
This updates the ipc lifetimeEvent comments to match reality.  In
particular, lifetimeEventTicketDB was previously removed but the
comments were not updated to reflect this.
2021-04-28 10:27:55 -05:00
Ryan Staudt
133bd0079f blockchain: Move UTXO DB tests to separate file.
This moves the tests that deal with the UTXO database buckets from
chainio_test.go to a separate file, utxoio_test.go.

This is part of moving the UTXO set and state to a separate database.
2021-04-28 10:27:55 -05:00
Ryan Staudt
82fe569171 blockchain: Move UTXO DB methods to separate file.
This moves the methods that deal with the UTXO database buckets from
chainio.go to a separate file, utxoio.go.

This is part of moving the UTXO set and state to a separate database.
2021-04-28 10:27:55 -05:00
Jonathan Chappelow
0b39e530e7
rpcserver: Allow gettreasurybalance empty blk str.
When an empty string is provided for the optional block hash argument,
this should be treated as if it were omitted rather than the zero hash,
which is an invalid block.

This changes handleGetTreasuryBalance to treat "" like nil. This change
is consistent with how handleGetTreasurySpendVotes handles its optional
block argument.

The tests for both gettreasurybalance and gettreasuryspendvotes are
updated to ensure this behavior (existing for gettreasuryspendvotes).
2021-04-27 13:02:07 -05:00
Dave Collins
56d00f5650
blockchain: Use agenda flags for tx check context.
This modifies checkTransactionContext to accept agenda flags instead of
a boolean for whether or not the treasury agenda is active so it is
easier to extend  for future consensus votes which would otherwise
require a series of boolean parameters.
2021-04-27 05:33:24 -05:00
Dave Collins
02567db254
blockchain: Trsy always inactive for genesis blk.
This modifies the IsTreasuryAgendaActive method to return false when a
zero hash is provided since that indicates the next block is the genesis
block and the treasury agenda is always inactive for the genesis block.

This has the effect of fixing a few RPC handlers, such as getblock, when
working with the genesis block.
2021-04-22 12:26:12 -05:00
JoeGruff
cd76b0799b rpcserver: Add median time to verbose results.
Median time is a useful value to return to clients, saving them the
trouble of calculating it themselves. Include the value in verbose
getblock and getblockheader results.
2021-04-22 11:26:10 -05:00
Dave Collins
dd2a786ee1
blockchain: Prerel module release ver updates.
This modifies the recently-updated blockchain module to use a valid
prerelease version of the blockchain/stake module so it can be used in
require statements in consumer code that is also under development.

The updated direct dependencies are as follows:

- github.com/decred/dcrd/blockchain/stake/v4@v4.0.0-20210409183916-7f402345f0a6
2021-04-15 17:59:37 -05:00
Dave Collins
1012d90f4b
dcrutil: Remove all code related to Address.
This removes all code related to defining and implementing the Address
type since that is now handled by the stdaddr package.
2021-04-15 16:58:35 -05:00
Dave Collins
0fb3e7eabd
dcrutil: Convert to use new stdaddr package.
This updates VerifyMessage to use the stdaddr package for addresses
instead of the local Address type in preparation for its removal.
2021-04-15 16:58:25 -05:00
Dave Collins
cf956d229c
dcrutil: Move address params iface and mock impls.
This moves the AddressParams interface and associated mock
implementations in the tests to util.go and util_address.go,
respectively, in preparation for removing the Address type and related
code.
2021-04-15 16:51:52 -05:00
Josh Rickmar
96b98390a9 stdaddr: Replace Address method with String
An address is conceptually a human-readable string encoding of a
payment script, so the two methods String and PaymentScript should be
sufficient to provide basic address functionality.  This also avoids
some stutter/repetition (e.g. ma.Address().Address()) in wallet code,
where wrapper types are used around the Address interface, and
additionally allows the wrapper types to implement the stdaddr.Address
interface directly while still providing their own Address method to
return the underlying interface type.
2021-04-15 16:51:33 -05:00
Dave Collins
76f80ba180
txscript: Break dcrutil dependency.
Now that the addresses have all been converted over to use the stdaddr
package, this removes only remaining dependencies on dcrutil which are
in the tests in order to avoid cyclic dependencies when updating the
dcrutil code to the use the stdaddr package.
2021-04-12 11:21:01 -05:00
Dave Collins
12c4e56a73
txscript: Remove unused ErrUnsupportedAddress.
This removes the ErrUnsupportedAddress error kind since it is no longer
needed by anything in the package.
2021-04-12 01:38:19 -05:00
Dave Collins
76d625dfd0
txscript: Remove unused GenerateSStxAddrPush.
This removes GenerateSStxAddrPush since it is no longer used by anything
in the repository and is now available via the RewardCommitmentScript
method of the relevant stdaddr address.

It also removes the associated tests and nilAddrErrStr that is no longer
used upon their removal.
2021-04-12 01:38:19 -05:00
Dave Collins
19fa54d62c
txscript: Remove unused payToPubKeyHashScript.
This removes payToPubKeyHashScript since it is no longer used by
anything in the package and is now available via the PaymentScript
method of the relevant stdaddr address.
2021-04-12 01:38:19 -05:00
Dave Collins
b786479c86
txscript: Remove unused payToPubKeyHashEdwardsScript.
This removes payToPubKeyHashEdwardsScript since it is no longer used by
anything in the package and is now available via the PaymentScript
method of the relevant stdaddr address.
2021-04-12 01:38:18 -05:00
Dave Collins
6802f12691
txscript: Remove unused payToPubKeyHashSchnorrScript.
This removes payToPubKeyHashSchnorrScript since it is no longer used by
anything in the package and is now available via the PaymentScript
method of the relevant stdaddr address.
2021-04-12 01:38:18 -05:00
Dave Collins
84038fd69f
txscript: Remove unused payToScriptHashScript.
This removes payToScriptHashScript since it is no longer used by
anything in the package and is now available via the PaymentScript
method of the relevant stdaddr address.
2021-04-12 01:38:18 -05:00
Dave Collins
dc6a5910ac
txscript: Remove unused payToPubKeyScript.
This removes payToPubKeyScript since it is no longer used by anything in
the package and is now available via the PaymentScript method of the
relevant stdaddr address.
2021-04-12 01:38:17 -05:00
Dave Collins
f05a2ded1a
txscript: Remove unused payToEdwardsPubKeyScript.
This removes payToEdwardsPubKeyScript since it is no longer used by
anything in the package and is now available via the PaymentScript
method of the relevant stdaddr address.
2021-04-12 01:38:17 -05:00
Dave Collins
5cc2db80e4
txscript: Remove unused payToSchnorrPubKeyScript.
This removes payToSchnorrPubKeyScript since it is no longer used by
anything in the package and is now available via the PaymentScript
method of the relevant stdaddr address.
2021-04-12 01:38:17 -05:00
Dave Collins
7c51528dc2
txscript: Remove unused PayToScriptHashScript.
This removes PayToScriptHashScript since it is no longer used by
anything in the repository and is now available via the PaymentScript
method of the relevant script hash stdaddr address.
2021-04-12 01:38:16 -05:00
Dave Collins
ac34bc195e
txscript: Remove unused PayToAddrScript.
This removes PayToAddrScript and its associated example since it is no
longer used by anything in the repository and is now available via the
PaymentScript method of the relevant stdaddr address.
2021-04-12 01:38:16 -05:00
Dave Collins
8f7ede4b10
txscript: Remove unused PayToSSRtxSHDirect.
This removes PayToSSRtxSHDirect since it is no longer used by anything
in the repository and is now available via the PayRevokeCommitmentScript
method of the relevant script hash stdaddr address.
2021-04-12 01:38:16 -05:00
Dave Collins
981751c86a
txscript: Remove unused PayToSSRtxPKHDirect.
This removes PayToSSRtxPKHDirect since it is no longer used by anything
in the repository and is now available via the PayRevokeCommitmentScript
method of the relevant pubkey hash stdaddr address.
2021-04-12 01:38:15 -05:00
Dave Collins
9727f128fa
txscript: Remove unused PayToSSRtx.
This removes PayToSSRtx since it is no longer used by anything in the
repository and is now available via the PayRevokeCommitmentScript method
of the relevant stdaddr addresses.
2021-04-12 01:38:15 -05:00
Dave Collins
ff99da2fac
txscript: Remove unused PayToSSGenPKHDirect.
This removes PayToSSGenPKHDirect since it is no longer used by anything
in the repository and is now available via the PayVoteCommitmentScript
method of the relevant pubkey hash stdaddr address.
2021-04-12 01:38:15 -05:00
Dave Collins
22de715c18
txscript: Remove unused PayToSSGenSHDirect.
This removes PayToSSGenSHDirect since it is no longer used by anything
in the repository and is now available via the PayVoteCommitmentScript
method of the relevant script hash stdaddr address.
2021-04-12 01:38:14 -05:00
Dave Collins
486a89dadc
txscript: Remove unused PayToSSGen.
This removes PayToSSGen since it is no longer used by anything in the
repository and is now available via the PayVoteCommitmentScript method
of the relevant stdaddr addresses.
2021-04-12 01:38:14 -05:00
Dave Collins
777a7e57f0
txscript: Remove unused PayToSStxChange.
This removes PayToSStxChange since it is no longer used by anything in
the repository and is now available via the StakeChangeScript method of
the relevant stdaddr addresses.
2021-04-12 01:38:14 -05:00
Dave Collins
21b91f8b4e
txscript: Remove unused PayToSStx.
This removes PayToSStx since it is no longer used by anything in the
repository and is now available via the VotingRightsScript method of the
relevant stdaddr addresses.
2021-04-12 01:38:13 -05:00
Dave Collins
59d8db038f
txscript: Convert to use new stdaddr package.
This converts the txscript package to use the stdaddr package instead of
dcrutil.Address as well as to support script versions.

All callers that use the package in the repository are updated
accordingly to maintain code that continues to build and work properly
as well as pass all tests.  In order to achieve this, some previously
temporary address conversion code that is no longer needed is removed
from the blockchain/indexers and internal/rpcserver packages.

This is part of a series of commits to convert all packages in the
repository to make use of the new stdaddr package.
2021-04-12 01:38:08 -05:00
Dave Collins
4007dcde64
hdkeychain: Convert to use new stdaddr package.
This converts the hdkeychain package example to use the stdaddr package
instead of dcrutil.Address.

This is part of a series of commits to convert all packages in the
repository to make use of the new stdaddr package.
2021-04-09 13:39:19 -05:00
Dave Collins
8dbdd74a62
rpcserver: Convert to use new stdaddr package.
This converts the internal/rpcserver package to use the stdaddr package
instead of dcrutil.Address as well as to support script versions.

All callers that use the package in the repository are updated
accordingly to maintain code that continues to build and work properly
as well as pass all tests.  In order to achieve this, it introduces
temporary address conversion code that will be removed in future
commits.

This is part of a series of commits to convert all packages in the
repository to make use of the new stdaddr package.
2021-04-09 13:39:19 -05:00
Dave Collins
d1e36b56f8
rpctest: Convert to use new stdaddr package.
This converts the rpcclient package to use the stdaddr package instead
of dcrutil.Address as well as to support script versions.

All callers that use the package in the repository are updated
accordingly to maintain code that continues to build and work properly
as well as pass all tests.

This is part of a series of commits to convert all packages in the
repository to make use of the new stdaddr package.
2021-04-09 13:39:18 -05:00