Commit Graph

6262 Commits

Author SHA1 Message Date
Dave Collins
94f64eaaff
rpcclient: Remove existsmissedtickets.
This removes support for the deprecated existsmissedtickets method from
the RPC client.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:20 -05:00
Dave Collins
77cbb2cdca
docs: Remove existsmissedtickets JSON-RPC API.
This removes the deprecated existsmissedtickets method from the JSON-RPC
API documentation.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:20 -05:00
Dave Collins
fffbae79e9
jsonrpc/types: Remove rebroadcastmissed.
This removes the type and associated code for the deprecated
rebroadcastmissed RPC.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:19 -05:00
Dave Collins
1636ed77c4
blockchain: Remove unused MissedTickets.
This removes the MissedTickets method from blockchain now that it is no
longer used.
2022-04-30 00:16:19 -05:00
Dave Collins
09d6eb2866
rpcserver: Remove rebroadcastmissed RPC.
This removes the deprecated rebroadcastmissed method from the RPC
server.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:18 -05:00
Dave Collins
1f7c6b2a6d
docs: Remove rebroadcastmissed JSON-RPC API.
This removes the deprecated rebroadcastmissed method from the JSON-RPC
API documentation.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:18 -05:00
Dave Collins
61ff5e50ba
jsonrpc/types: Remove deprecated missedtickets.
This removes the types and associated code for the deprecated
missedtickets RPC.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:18 -05:00
Dave Collins
b49e6e7dbc
rpcserver: Remove missedtickets RPC.
This removes the deprecated missedtickets method from the RPC server.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:17 -05:00
Dave Collins
c692f441a1
rpcclient: Remove missedtickets.
This removes support for the deprecated missedtickets method from the
RPC client.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:16 -05:00
Dave Collins
201f266028
docs: Remove missedtickets JSON-RPC API.
This removes the deprecated missedtickets method from the JSON-RPC API
documentation.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:16 -05:00
Dave Collins
c70926e95c
rpcserver: Bump version to 8.0.0.
This bumps the major version of the JSON RPC server in anticipation of
upcoming changes to remove deprecated RPCs related to missed and expired
tickets.

This is part of the overall removal of deprecated RPCs related to missed
and expired tickets.
2022-04-30 00:16:16 -05:00
Dave Collins
f5cf638053
primitives: Update README.md for subsidy calcs.
This updates the primitives module README.md to include the
recently-added subsidy calculation capabilities.
2022-04-30 00:00:55 -05:00
Donald Adu-Poku
37dea95657 docs: add backport documentation.
This adds a documentation section detailing what is
expected for backported pull requests.
2022-04-29 13:30:35 -05:00
Donald Adu-Poku
d47a89723b server: Fix syncNotified race.
This fixes a race with the syncNotified field of a serverPeer.
2022-04-29 12:56:47 -05:00
Dave Collins
495414b7d4
chaingen: Update for deprecated subsidy params.
This update the test chain generator to use hard coded values for the
subsidy calcs since the chaincfg params are now deprecated and the
values are the same for all networks.
2022-04-27 19:14:51 -05:00
Donald Adu-Poku
c25315ada2 rpcserver: cleanup queueHandler process.
This updates wsNotificationManager queueHandler to avoid checking if the
channel is closed since it never is. The out label is also removed in
favour of doing needed cleanup on context cancellation.
2022-04-27 18:47:19 -05:00
Dave Collins
71243992b4
primitives: Add subsidy calc benchmarks.
CalcSubsidyCacheSparse   26023311   45.99 ns/op   0 B/op   0 allocs/op
CalcWorkSubsidy          21051818   52.12 ns/op   0 B/op   0 allocs/op
CalcStakeVoteSubsidy     22216708   53.44 ns/op   0 B/op   0 allocs/op
CalcTreasurySubsidy      22610749   49.78 ns/op   0 B/op   0 allocs/op
2022-04-25 17:53:38 -05:00
Dave Collins
3257fe15e0
primitives: Add subsidy calcs.
This implements a subsidy cache with funcs to calculate subsidies for
proof-of-work, votes, and the treasury and includes a full suite of
tests.

It consists of ports of the related code in blockchain/standalone with
the following modifications:

- Removes the subsidy split parameters from SubsidyParams since the
  chaincfg implementations are deprecated
  - Uses hard-coded constants for the PoW, PoS, and treasury splits both
    prior to and after the activation of DCP0010
- Removes the version 1 methods and renames the version 2 variants to
  take their place:
  - CalcWorkSubsidyV2 -> CalcWorkSubsidy
  - CalcStakeVoteSubsidyV2 -> CalcStakeVoteSubsidy
- Consolidates the tests specific to the decentralized treasury agenda
  into their counterparts
- Includes additional maintainer notes with the expected way to update
  the code without needing a major module bump should it ever be
  necessary
2022-04-25 17:53:34 -05:00
Dave Collins
b09bed396f
blockchain/stake: Address some linter complaints. 2022-04-19 19:07:17 -05:00
Dave Collins
00c8219b8b
connmgr: Address some linter complaints. 2022-04-19 19:07:17 -05:00
Dave Collins
4716224ece
dcrjson: Address some linter complaints. 2022-04-19 19:07:16 -05:00
Dave Collins
ca0e41269f
blockchain: Address some linter complaints. 2022-04-19 19:07:13 -05:00
matthawkins90
7d665db7c9 docs: Update doc.go with latest arguments. 2022-04-18 21:29:15 -05:00
Ryan Staudt
9ec3acc103 multi: Fix a few typos. 2022-04-12 14:44:51 -05:00
David Hill
a6db99aed6 ecdsa: Fix test that randomly picks a component. 2022-04-12 14:42:52 -05:00
David Hill
d27b34cb48 stake: Use a single copy instead of a for loop. 2022-04-12 14:42:52 -05:00
David Hill
2b9a9cc66c blockchain: Remove unused params. 2022-04-11 17:22:18 -05:00
Dave Collins
ab6d2fb8a6
chaincfg: Deprecate subsidy split params.
This deprecates the per-network subsidy split parameters for the
following reasons.

- They are the same on all networks so there really is no good reason to
  parameterize them as such
- The subsidy calculation code can be simplified and made slightly more
  efficient without the unnecessary parameterization
2022-04-07 11:13:40 -05:00
Dave Collins
b2be01a0b7
secp256k1/ecdsa: Rework rand compact sig tests.
This reworks the tests that deal with signing random messages with
random private keys and recovering the associated public key to make
them more consistent with modern practices in the code as well as to
expand the testing methodology to include additional assurances.

Specifically, the relevant test now:

- Signs random representative hashes instead of a fixed non-hashed message
- Signs, recovers, and verifies both the compressed and uncompressed
  public key variants for each iteration
- Ensures mutating a random bit in the good signature results in failure
  to recover the original public key
- Ensures mutating a random bit in the message hash that was originally
  signed results in failure to recover the original public key from the
  good signature
2022-04-07 11:07:50 -05:00
Dave Collins
ef5e3f7cde
secp256k1/ecdsa: Add compact signature tests.
This adds tests for compact signature generation and associated public
key recovery for both the positive and negative paths.

The following is a high-level overview of the changes:

- Add tests to ensure test data that was independently verified with the
  Sage computer algebra system produces the expected results
- Add tests which are specifically designed to exercise all of the
  recovery failure paths
2022-04-07 11:07:46 -05:00
Dave Collins
d205e99708
secp256k1/ecdsa: Consistent sig recovery errors.
This converts the error handling in compact signature recovery to be
consistent with the rest of the code base such that it returns concrete
errors that support errors.Is/As and thus are programmatically
detectable by callers.
2022-04-07 10:42:10 -05:00
David Hill
8e45fc5ca0 internal/mempool: remove unused isTreasuryEnabled param. 2022-04-06 20:48:53 -05:00
David Hill
bb84081398 internal/mining: createCoinbaseTx never returns an error. 2022-04-06 20:48:53 -05:00
Dave Collins
5a3f08293b
blockchain: Optimize old block ver upgrade checks.
Currently the code that rejects old block versions once the majority of
the network has upgraded is performed using a loop that iterates
backwards from latest enforced block version while checking for a
majority upgrade at each version.  This is inefficient for blocks early
in the chain since it means multiple versions need to be checked when it
isn't really necessary.

This optimizes the relevant code by taking into account that the
relevant enforcement semantics reduce to the following:

- Block versions greater than or equal to the latest enforced block
  version can never be rejected for being old
- Block versions must be rejected when the majority of the network has
  upgraded to ANY version greater than that version

The following timing information obtained from profiling shows the
overall reduction achieved with the optimized code for mainnet:

 existing: Total time to check old versions for 645603 headers: 10.61118s
optimized: Total time to check old versions for 645603 headers:  3.52555s
2022-04-06 12:48:47 -05:00
Dave Collins
d9ba0b9364
secp256k1/ecdsa: Add rand sign and verify tests.
This adds a test to sign and verify random data in addition to the
existing tests the deal with known good data and edge conditions.

Specifically, the test:

- Generates random keys and messages with each run from a new random
  seed and log that seed in the event of failure
- Signs the rand message with the random key and ensures the produced
  signature verifies correctly
- Ensures mutating a random bit in each good signature results in that
  mutated signature failing to verify the original message
- Ensures mutating a random bit in each message hash that was originally
  signed results in the original good signature failing to verify the
  new mutated message
2022-03-30 22:59:06 -05:00
Dave Collins
ec37a37601
secp256k1/ecdsa: Add sign and verify tests.
Although the ECDSA code has been extensively tested through usage and
external fuzz testing, there are not currently any unit tests for the
non-compact signing and verification path.

This resolves that by adding signing and verification tests for both the
positive and negative paths.  The following is a high-level overview of
the changes:

- Create new known good test data that is easily reproducible and has
  been independently verified with the Sage computer algebra system
  - The test data includes the original messages so the resulting hashes
    are independently verifiable and have a known source
  - The test data includes variations of signing the same data with
    different keys and nonces, both deterministically generated via
    RFC6979 and random, and signing different data with the same keys
- Add tests to ensure the aforementioned test data that was
  independently verified produces the expected results
- Add tests which are specifically designed to exercise conditions that
  lead to invalid signatures
- Add tests to help ensure the signature verification code fails to
  verify edge conditions as expected by crafting signatures that are
  specifically designed to hit them
2022-03-30 22:58:09 -05:00
Dave Collins
e248c488a1
secp256k1/ecdsa: Accept nonce in internal signing.
This refactors the primary logic for the regular ECDSA signing code to a
separate function that accepts an arbitrary nonce.  The primary
motivation is to facilitate upcoming unit tests which aim to fully test
both the positive and negative paths, however, it is also beneficial in
that it provides more flexibility for potentially using other nonce
generation mechanisms in the future should it be necessary.
2022-03-30 22:56:34 -05:00
Dave Collins
3c2ab8723c
secp256k1/ecdsa: Correct test comment. 2022-03-30 22:56:34 -05:00
Dave Collins
798914eb03
rpcclient: Start v8 module dev cycle.
Upcoming changes constitute breaking public API changes to the
rpcclient module, therefore, this follows the process for introducing
major API breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
2022-03-30 17:40:06 -05:00
Dave Collins
06b64fb977
rpc/jsonrpc/types: Start v4 module dev cycle.
Upcoming changes constitute breaking public API changes to the
rpc/jsonrpc/types module, therefore, this follows the process for
introducing major API breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
2022-03-30 17:34:29 -05:00
Dave Collins
cd1afb2afc
contrib: Add Go multimod workspace setup script.
This adds a script to the contrib directory that initializes a Go
multi-module workspace and adds all of the modules provided by the dcrd
repository to it on an as needed basis.  Note that workspaces require Go
1.18+.

This is useful when developing across multiple modules in the repository
and allows development environments that make use of the Go language
server (aka gopls), such as VSCode, to provide full support without also
needing to temporarily create replacements in the various go.mod files
or individually add every module.

Do note, however, that workspaces are local, so final submissions to the
repository will still require the appropriate changes to the relevant
go.mod files to ensure resolution outside of the workspace.

Finally, it also updates the README.md in the contrib directory
accordingly.
2022-03-29 12:06:51 -05:00
Donald Adu-Poku
fd038e36ce indexers: fix indexer wait for sync.
This fixes an issue with indexers wait for sync where the indexer gets
synced before a sync subcsriber is created. The sync subscriber is left
idling, waitingfor the next update which blocks the caller. The index
subscriber has been updated to periodically update sync subcribers
of all subscribed indexers to it as a result.
2022-03-28 18:25:34 -05:00
matthawkins90
6ec3707f98 docker: Update image to golang:1.18.0-alpine3.15.
This updates the docker image to golang:1.18.0-alpine3.15.
To find the new digest:
`docker pull golang:1.18.0-alpine3.15`
yields:
```
1.18.0-alpine3.15: Pulling from library/golang
3aa4d0bbde19: Pull complete
48ae170c2a8c: Pull complete
cb35b180f419: Pull complete
4b7aa5465d48: Pull complete
e21951e06724: Pull complete
Digest: sha256:6fd04df1b7ba6253a09b4bd3f37cc1fb69903a60209ef959485328b1c2902327
Status: Downloaded newer image for golang:1.18.0-alpine3.15
docker.io/library/golang:1.18.0-alpine3.15
```
2022-03-26 15:06:10 -05:00
Dave Collins
7d59dd3b69
multi: Support module graph prune and lazy load.
This bumps the go directive for all of the modules provided by the
repository to 1.17 which will allow the new module graph pruning and
lazy loading capabilities introduced in Go 1.17 to be used once the
updated modules are released.

This means that, as described by the documentation, the go.mod files for
each module now include a separate require block that includes all of
the indirect dependencies
2022-03-25 07:20:01 -05:00
matthawkins90
84058da9a7 docs: Update Min Recommended Disc Space
* Updated the minimum recommended Disc Space from 12 GB to 16 GB,
* Added an estimate of ~2 GB/yr
* Followed the SI style guide for units: A space is always used to separate the unit from
the number.
2022-03-25 07:18:28 -05:00
matthawkins90
0326321685 multi: Update Go versions in README.md and .github/workflows/go.yml
With the release of Go 1.18, the supported versions listed in the
README and used in the go.yml workflow should be 1.17 and 1.18.

Also update the golangci-lint to v1.45.2
2022-03-25 07:18:28 -05:00
Dave Collins
8d1038cc45
blockchain: Start v5 module dev cycle.
Upcoming changes constitute breaking public API changes to the
blockchain module, therefore, this follows the process for introducing
major API breaks which consists of:

- Bump the major version in the go.mod of the affected module if not
  already done since the last release tag
- Add a replacement to the go.mod in the main module if not already done
  since the last release tag
- Update all imports in the repo to use the new major version as
  necessary
- Make necessary modifications to allow all other modules to use the new
  version in the same commit
- Repeat the process for any other modules the require a new major as a
  result of consuming the new major(s)
2022-03-24 12:44:05 -05:00
Eng Zer Jun
fccb811eb2
blockchain: Use TempDir to create temp test dirs.
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

This commit also refactor several cleanup logic by using `t.Cleanup`
instead of `defer`.

Reference: https://pkg.go.dev/testing#T.TempDir
Reference: https://pkg.go.dev/testing#T.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-17 20:17:26 -05:00
Dave Collins
a0f9723016
build: Update to latest action versions.
This updates to the following Github Actions:

- actions/setup-go@f6164bd8c8 #v3.0.0
- actions/checkout@a12a3943b4 #v3.0.0
2022-03-17 19:34:58 -05:00
Dave Collins
aae0128d94
secp256k1: Reduce scalar base mult copies.
Profiling shows that around 7.5% of the time in scalar base
multiplication is attributed to duffcopy.  Upon further examination,
this is the result of a combination of the range statement making copies
of the bytes and the need to construct a Jacobian point from the
individual field values stored in the in-memory byte points table.

This optimizes the function to avoid that as follows:

- Perform the conversion to Jacobian once when the affine byte table is
  decompressed from the stored values
- Make use of those Jacobian points directly
- Use an indexed for loop instead of a range over the bytes
- Perform the calculation using the result variable directly instead of
  via a local variable that is copied to the result

The following benchmark results show the speedup is in line with the
expected gains per the profiling results:

name                     old time/op   new time/op    delta
------------------------------------------------------------------------------
ScalarBaseMultNonConst   24.1µs ±22%   22.5µs ± 2%   -6.97%  (p=0.000 n=98+96)
2022-03-17 19:31:50 -05:00