Commit Graph

5155 Commits

Author SHA1 Message Date
Dave Collins
9de5c1911c
contrib: Update simnet script for wallet cointype.
This modifies the dcr_tmux_simnet_setup.sh script to update the mining
and transfer addresses to account for the change to dcrwallet master
which always upgrades the cointype on simnet.
2020-08-17 12:00:33 -05:00
Dave Collins
f1d6b2fc10
peer: Update README.md/doc.go to reflect reality. 2020-08-16 19:14:38 -05:00
Dave Collins
3e0e466ac0
contrib: Use var for simnet wallet create answers.
This modifies the dcr_tmux_simnet_setup.sh script to use a variable to
consolidate wallet creation answers instead of a file so there are no
artifacts left.
2020-08-12 13:17:24 -05:00
Dave Collins
f06d7edfdd
contrib: Support env var in simnet setup script.
This modifies the dcr_tmux_simnet_setup.sh script to set the root of all
of the nodes to the environment variable DCR_SIMNET_ROOT when it is set
and fallback to the existing path when it is not.

It also updates contrib/README.md and docs/simnet_environment.mediawiki
to document the new capability.
2020-08-12 12:42:08 -05:00
Josh Rickmar
3cb62b9eeb contrib: Update simnet script for dcrwallet master
The prompts when creating the wallet were changed when the wallet
passphrase was part of the application configuration, which caused the
script to hang.  This fixes the hang by replying to the additional
prompt, and updates the script to pipe input to dcrwallet's stdin to
reply to the prompts, rather than using tmux to send keys.
2020-08-11 13:01:43 -05:00
JoeGruff
3d3034d11e rpcserver: Add handleExistsMempoolTxs test. 2020-08-07 21:42:39 -05:00
JoeGruff
e7cbd9985a rpcserver: Add TxMempooler interface.
In order to allow tests to use mocked mempool transaction data, replace
the RPC server's TxMemPool with an interface that satisfies what is
needed for the server.
2020-08-07 21:42:39 -05:00
Donald Adu-Poku
a85e1525b9 rpcserver: add setgenerate & regentemplate tests.
This adds rpc tests for setgenerate and regentemplate.
2020-08-06 21:22:06 -05:00
Dave Collins
44de32a309
config: Categorize options in the code.
This categorizes the various configuration options in the code to
improve readability.

It also updates the doc.go CLI options reference to reflect reality.
2020-08-06 09:50:19 -05:00
Dave Collins
d6afeac8b0
blockchain: Migration for v3 block index.
This adds the code to migrate the database to a new v3 block index.

It involves removing the ticket hashes associated with vote info and
revocations that are no longer needed.  The process can be interrupted
at any point and future invocations will resume from the point it was
interrupted.
2020-08-06 09:46:13 -05:00
Dave Collins
f97951dc7d
blockchain: Remove superfluous blockidx fields.
Originally, some information that is related to vote ticket hashes and
revocations was added to the block index because it was needed prior to
the full node index being available and also because there was no
dynamic loading of the relevant stake node information in various
circumstances which meant the information had to be available on the
nodes at all times.

However, since that time, things have changed quite a bit such that the
full block index is now available in memory, the stake nodes and related
information are now efficiently loaded on demand, and stake node pruning
has been optimized accordingly.

As a result, it no longer makes sense to store all of this information.

Profiling shows this reduces the total inuse memory by about 19.5%.
2020-08-06 09:46:12 -05:00
Dave Collins
165b3b463b
blockchain: Use static log funcs for static logs. 2020-08-06 09:46:09 -05:00
Donald Adu-Poku
032e8f0a5b multi: add getwork tests.
This fixes a proof of work error check and
adds rpc handler tests for getWork.
2020-08-06 09:41:57 -05:00
Dave Collins
9bff4d1466
contrib: Support MSYS2 in simnet setup script.
This modifies the simnet environment setup script to make use of winpty
when running under MSYS2 so that it works properly there.
2020-08-04 22:05:38 -05:00
Dave Collins
fa984bfabf
contrib: Respect quoted args in simnet ctl scripts.
This modifies the ctl convenience scripts generated by the the simnet
environment setup script to respect quoted arguments passed to it.
2020-08-04 17:04:33 -05:00
JoeGruff
7b0968b7e1 rpcserver: Add exists upper bounds TODOs.
Although permissioned, the RPC server will allow for checking any number
of values for its various exists commands. It would be reasonable to
limit unreasonable requests that could exhaust dcrd's available memory
and cause node failure. Changes will come with a major RPC version bump.
2020-08-01 17:25:18 -05:00
JoeGruff
e74e4e5573 rpcserver: Add handleExistsAddresses test. 2020-08-01 17:25:18 -05:00
JoeGruff
6307a35ebb rpcserver: Add handleExistsAddress test.
This removes the ExistsAddrIndex method from the SyncManager interface
and replaces it with a new interface ExistsAddresser that supplies the
two methods used by the rpcserver, ExistsAddress and ExistsAddresses.
2020-08-01 17:25:18 -05:00
Ryan Staudt
e5bc899c97 docs: Document additional ws notifications.
This adds documentation for the following ws notifications:
  - notifywinningtickets
  - notifyspentandmissedtickets
  - notifynewtickets
  - notifystakedifficulty
2020-08-01 02:10:19 -05:00
Dave Collins
f30b10f952
multi: Add simnet documentation and setup script.
This adds a script for simplifying simnet usage by creating a fresh
version of a preconfigured environment each time it is started along
with documentation that provides information regarding simnet, how to
make use of the script and environment, including some basic tasks and
common issues, as well as some information about manual configuration.

This script is something that has evolved over the years from one I
originally wrote and was later modified by Matheus Degiovani to make use
of tmux.  The version provided here also contains some new features and
convenience scripts that were written specifically to help newer users
and simplify common tasks such as performing a chain reorganization and
shutting down the environment.

Some of the documentation is based on a gist I created a long time ago,
which was then converted to the content currently on the documentation
site, but this is a much more polished version that includes the extra
information about the script and associated environment it provides and
is better served alongside the script in the repository.
2020-08-01 02:04:36 -05:00
Dave Collins
d283942634
contrib: Add README.md.
This adds a README.md to describe the intended purpose of the contrib
directory as well as the current existing items.
2020-08-01 02:01:35 -05:00
Dave Collins
6e09791def
release: Remove no longer used release bits.
This removes the release directory since it hasn't been used for a very
long time, is no longer necesssary, and is no longer accurate either.
2020-08-01 02:01:35 -05:00
Dave Collins
5419aa559f
contrib: Move service config examples to contrib. 2020-08-01 02:01:32 -05:00
Dave Collins
73c6314422
blockchain: Move stxo source to chain.
This moves the stxosToScriptSource function from upgrade.go to chain.go
to properly indicate that it is used in more than the upgrade code path.
2020-07-31 19:24:06 -05:00
Dave Collins
c2b9ca89dc
docs: Add several historical release notes. 2020-07-31 18:56:41 -05:00
Ryan Staudt
07b7fd3374 rpcserver: Document v1 cfilters as deprecated.
This documents the v1 cfilters and related rpcserver handlers,
documentation, and help as deprecated.
2020-07-31 17:48:21 -05:00
Ryan Staudt
1bc0a53b8c docs: Add documentation for getcfilterheader. 2020-07-31 17:48:21 -05:00
Ryan Staudt
0c3abbecbb rpcserver: Add handleGetCFilterV2 tests. 2020-07-31 17:48:21 -05:00
Ryan Staudt
72ebb6040e rpcserver: Add handleGetCFilterHeader tests. 2020-07-31 17:48:21 -05:00
Ryan Staudt
40e8a97216 rpcserver: Add handleGetCFilter tests. 2020-07-31 17:48:21 -05:00
Ryan Staudt
66625a413d rpcserver: Add Filterer and FiltererV2 interfaces.
This adds Filterer and FiltererV2 interfaces to rpcserver, which
decouples rpcserver from the implementation to retrieve committed
filters and allows mocked versions to be provided for testing.
2020-07-31 17:48:21 -05:00
Dave Collins
157995d932
connmgr: Improve dial timeout test synchronization .
This modifies the dial timeout test to make use of a channel for the
cancellation signal synchronization instead of a sleep to prevent false
positive test failures in slower environments such as CI servers.
2020-07-29 20:47:20 -05:00
Dave Collins
6c6da6df18
blockchain: Optimize chain tip tracking.
Part of adding nodes to the block index involves updating the current
chain tip in order to be able to efficiently keep track of all known
chain tips.

Since there can be multiple tips at a given height, the current code
uses a slice for each height to track them.  However, this is wasteful
since it is extremely rare for there to be more than one chain tip at
the same height.

It is particularly notable at startup since the block index has to load
up hundreds of thousands of nodes.

Given that, this modifies the chain tip tracking logic to avoid creating
a slice unless it is actually needed by making use of an entry with a
static field for the normal case and a dynamic slice for the case when
more than 1 tip for the height actually exists.

It also keeps a running sum of the total number of known chips for use
as a hint to further reduce allocations when serving up related data and
updates the chain tip tests to ensure 100% branch coverage is maintained.

The end result is that  this reduces the total number of allocs at
startup by around 1%, which results in faster startup, and also reduces
the overall memory usage by a few MB for nodes that have a long running
history of side chains.
2020-07-29 19:25:03 -05:00
Dave Collins
125fc41c76
peer: Optimize logging.
Similar to the recent changes made to txscript logging, this updates the
peer code to take advantage of the ability to determine the logging
level when constructing expensive log strings in order to avoid the
allocations caused by closures and removes the no longer necessary code
related to creating them.
2020-07-28 16:51:48 -05:00
Dave Collins
f2839da8d1
txscript: Optimize trace logging.
After recent optimizations, the current next biggest offender of more
allocations than would be expected revealed by profiling is due to the
trace logging closures for the scripting engine execution.

Once upon a time, there was no way to check the current logging level
with the logging infrastructure at the time and thus a logging closure
was used to defer the fairly expensive construction of the trace logging
information until it was actually invoked (meaning tracing is enabled).

However, those closures come at the cost of allocations, and since
script execution is something that happens non-stop during normal
operation, those allocations really add up, as the profiling shows.

As some point, the logging infrastructure was changed out, and it is now
possible to determine the logging level, so this updates the code to
take advantage of that and avoid the closures while still only
performing the fairly expensive construction of trace logging
information when tracing is enabled. In other words, with this change
there is zero cost (other than the conditional check, of course) when
tracing is not enabled.

Finally, this also removes the no longer necessary code related to
creating the logging closures.
2020-07-28 16:48:20 -05:00
Dave Collins
b570934648
txscript: Optimize alt stack drop.
Profiling shows that approximately 0.67% of the total allocations are
coming from DropN even though it should realistically be zero.

The cause is that DropN returns an error if it is called with 0 and the
code that drops the alternate data stack in between scripts calls it
with the depth of the alternate data stack, which is almost always zero.

The call has no observable effect on the result of the script execution
in that case since the error is intentionally ignored, there is nothing
to be dropped, and is therefore correct semantically, however, it is
wasteful to generate and throw away the error.

There really is no good reason for the internal stack implementation to
return an error from DropN when called with 0 since it equivalent to a
NOP.

I have done a careful analysis of all call sites to ensure the change
will break any observable semantics.

Thus, this modifies DropN to remove the unnecessary error condition and
updates the associated internal stack implementation test accordingly.
2020-07-28 16:44:34 -05:00
Dave Collins
726178a13d
blockchain: Remove internal dbnamespace package.
This removes the internal blockchain/dbnamespace package in favor of
defining the bucket names and keys locally in the file that works with
them in the blockchain package.

An internal package for this gives the false impression that there is
some expectation that other packages in the module would be digging
around in the internals of what is intended to be an implementation
detail of the package.

It would also significantly complicates the ability to change the
database implementation.
2020-07-28 15:46:06 -05:00
Josh Rickmar
488369379c rpcserver: Sort getpeerinfo results by ID
The IDs are assigned in increasing order, so this has the net effect
of peer results returned in the order they were connected.  It also
keeps the order the same across multiple calls.

This matches the behavior of the current pull request implementing
getpeerinfo in dcrwallet.
2020-07-28 15:45:18 -05:00
Dave Collins
7e099b7edc
multi: Resolve go1.15 vet complaints. 2020-07-28 11:15:03 -05:00
Dave Collins
acc0174b44
txscript: Check equality via secp256k1 methods.
This modifies the signature cache Exists method to make use of the new
efficient equality testing methods provided by the secp256k1 types
versus indirectly checking their equality via their serializations.

The following benchmark shows a before and after comparison of a typical
signature cache exists check:

name             old time/op     new time/op     delta
-------------------------------------------------------------------------
SigCacheExists   400ns ± 0%      62ns ± 0%       -84.54%  (p=0.000 n=5+5)

name             old alloc/op    new alloc/op    delta
--------------------------------------------------------------------------
SigCacheExists   256B ± 0%       0B              -100.00%  (p=0.008 n=5+5)

name             old allocs/op   new allocs/op   delta
--------------------------------------------------------------------------
SigCacheExists   4.00 ± 0%       0.00            -100.00%  (p=0.008 n=5+5)
2020-07-27 21:30:54 -05:00
Dave Collins
a4e2443a74
rpcserver: Use internal quit chan for ws sync.
This modifies the websocket notification manager to make use of the
newer pattern that synchronizes the Run context with an internal quit
channel to ensure that any exported functions that communicate with the
goroutines can't possibly hang during shutdown.

This was previously done by storing the context in the struct (which is
generally discouraged) and protecting it by a mutex which means every
single notification had to take the mutex.

As can be seen by the diff of this commit, this approach is not only
more performant, it's also less code.
2020-07-27 18:58:01 -05:00
Dave Collins
d7532bd518
blockchain: Optimize stake node pruning.
Profiling revealed that the number one cause of allocations in
blockchain is currently due to stake node pruning, which definitely
should not be the case.

Upon closer examination, the culprit is that every single time the stake
nodes are pruned the entire ancestry of nodes prior to the prune height,
including those that have already been pruned, are appended to the list
of nodes to prune.  In practice, this amounts to hundreds of thousands
of nodes and thus the slice is resized multiple times (likely around
18 times per run given the current runtime semantics).

This remedies that by ensuring that only the nodes that actually need to
be pruned are added to the relevant slice and also preallocating space
per a hint that will handle the number of nodes expected to be pruned
with a 99% confidence level to further reduce allocations when more than
a single node needs to be pruned.

It also renames the slice to reflect what it actually does.
2020-07-27 12:21:46 -05:00
Dave Collins
b0d9399c7d
blockchain: Set pruning interval to tgt block time.
This modifies the pruning logic to set the pruning interval to the
target block time for the given chain parameters instead of hard coding
a constant with the mainnet value.
2020-07-27 12:21:46 -05:00
Dave Collins
b1b24a0cfd
blockchain: Rename last prune time field.
This renames the field that tracks the last time the stake nodes were
pruned to lastPruneTime to more accurately reflect its purpose.
2020-07-27 12:21:45 -05:00
Donald Adu-Poku
f5085109e0 multi: add rpcCPUMiner adaptor.
This adds an rpc adaptor for cpu miner, handling cases
where the underlining miner being passed is nil.
2020-07-25 21:33:10 -05:00
Donald Adu-Poku
3ea786998e multi: add BlockTemplater interface.
This adds the BlockTemplater interface to the rpcserver
package. Its corresponding adapter has also been added.
2020-07-25 19:56:02 -05:00
Donald Adu-Poku
5a1c705165 rpcserver: add verifychain & getdifficulty tests.
This adds rpc tests for the verifychain and getdifficulty rpcs.
2020-07-25 19:43:16 -05:00
Donald Adu-Poku
ee0d826094 multi: add rpcserver.CPUMiner.
This adds the rpcserver.CPUMiner interface to
facilitate cpu miner related rpc tests.
2020-07-25 19:28:02 -05:00
Donald Adu-Poku
dcddbbabb4 multi: add SanityChecker interface.
This adds the sanity checker interface and update
the function signature of CheckBlockSanity.
Associated tests and mocks updated/added.
2020-07-25 19:17:27 -05:00
Dave Collins
f73d738c24
main: Simplify startup logic slightly.
This modifies the main startup logic to make use of the fact that the
server now has its lifecycle tied to the same context that is cancelled
when a shutdown signal is received.

The end result is that the separate goroutine it was running in before
and associated synchronization logic is no longer necessary.
2020-07-25 18:14:55 -05:00