Commit Graph

6361 Commits

Author SHA1 Message Date
Matheus Degiovani
32ee3fb74d
rpcserver: Avoid error in handleRebroadcastWinners.
This downgrades an error when rebroadcasting the winning tickets to a
logged warning.

This is necessary because it is a legitimate state to have a chain tip
header returned by the Chain.TipGeneration() while the actual block data
is not yet available for the LotteryDataForBlock to complete.

Prior to this change, a voting wallet connecting to a dcrd instance with
multiple chain tip headers without the associated data would be unable
to re-start voting for blocks due to the associated RPC call failing.
2022-07-22 11:19:11 -05:00
Dave Collins
75f1b4dac2
blockchain: Remove leftover treasury debug logging. 2022-06-30 13:01:02 -05:00
Dave Collins
97c0ac9d04
mempool/docs: Update low-fee/free tx policy removal.
This is part of the overall removal of the low-fee/free tx relay policy
and associated rate limiting.
2022-06-29 13:07:06 -05:00
Dave Collins
2aa8b7f7e3
mempool: Remove ProcessTransaction rate limit.
This removes the rate limit flag from ProcessTransaction since it is no
longer used.
2022-06-29 13:07:06 -05:00
Dave Collins
027c865d72
mempool: Remove MaybeAcceptTransaction rate limit.
This removes the rate limit flag from MaybeAcceptTransaction since it is
no longer used.

This is part of the overall removal of the low-fee/free tx relay policy
and associated rate limiting.
2022-06-29 13:07:06 -05:00
Dave Collins
7506933202
mempool: Remove maybeAcceptTransaction rate limit.
This removes the rate limit flag from maybeAcceptTransaction since it is
no longer used.

This is part of the overall removal of the low-fee/free tx relay policy
and associated rate limiting.
2022-06-29 13:07:05 -05:00
Dave Collins
199cd04efa
mempool: Remove unused insufficient priority error.
This removes ErrInsufficientPriority now that it is no longer used.

This is part of the overall removal of the low-fee/free tx relay policy
and associated rate limiting.
2022-06-29 13:07:05 -05:00
Dave Collins
fce1bdcd88
mempool: Do not accept low-fee/free transactions.
This removes the code that accepts transactions with low fees to the
mempool when they have sufficient priority along with the associated
rate limiting of such transactions.

It also updates the error message when a transaction does not pay a high
enough fee to clearly state it was rejected for that reason along with
the minimum fee it is required to pay.

Finally, it slightly reworks the low fee rejection logic to include all
types of transactions it applies to in the same check instead of
independently per type.

This is part of the overall removal of the low-fee/free tx relay policy
and associated rate limiting.
2022-06-29 13:07:04 -05:00
Dave Collins
83050d3dfe
config: Deprecate limitfreerelay CLI option.
This deprecates the --limitfreerelay CLI option and removes the
associated code that changes behavior based on the option.

This is part of the overall removal of the low-fee/free tx relay policy
and associated rate limiting.
2022-06-29 13:07:04 -05:00
Dave Collins
11f2e7708e
config: Deprecate norelaypriority CLI option.
Prior to the introduction of child-pays-for-parent (CPFP), it was
possible for transactions to essentially become stuck forever if they
didn't pay a high enough fee for miners to include them in a block.

In order to prevent this, a policy was introduced to allow relaying of
low-fee/free transactions based on a priority that is calculated based
on the fee as well as the age of coins being spent.  This means that the
priority slowly increases over time as the coins age to ensure such
transactions would eventually be relayed and mined.  Further, in order
to prevent abuse the behavior could otherwise allow, this policy
includes additional rate-limiting of these types of transactions.

While the policy served its purpose in the past, there are some
downsides such as:
- A confusing UX where transactions that don't pay enough fees and also
  aren't old enough to meet the dynamically changing priority
  requirements are rejected due to having insufficient priority instead
  of not paying enough fees as the user might expect
- The priority requirements dynamically change over time which leads to
  non-deterministic behavior and thus ultimately results in what appear
  to be intermittent/transient failures to users

Since the policy is no longer necessary given said transactions can now
simply use CPFP to increase the overall fee of the entire transaction
chain thereby ensuring they are mined, this is the first of a series of
commits to remove the aforementioned policy along with associated rate
limiting from the mempool and transaction relay.

Specifically, it deprecates the --norelaypriority CLI option and removes
the associated code that changes behavior based on the option.
2022-06-29 13:07:03 -05:00
Dave Collins
7cbdfca334
blockchain: Address some linter complaints. 2022-06-28 16:17:25 -05:00
Dave Collins
dc0351646f
mempool: Explicitly reject standalone treasurybase.
This updates the mempool to explicitly reject standalone treasurybases
and adds a test to ensure proper functionality.

Note that treasurybases are already rejected because IsCoinBaseTx
currently detects a treasurybase as a coinbase as well, but it is safer
to be explicit in case the coinbase detection function is updated in the
future to exclude treasurybases.

Also since treasurybases are rejected early, remove the code that deals
with special casing them later given there is no way the transaction is
one.
2022-06-28 16:09:29 -05:00
Dave Collins
db05fd9ceb
mempool: Use valid tx fees in test harness.
This modifies the test harness to create transactions that use valid
fees instead of zero fees and cleans up a couple of minor things in the
process.

Of particular note is TestMaybeAcceptTransactions which was reworked to
use the existing transaction chain generation func and calculate the
expected ancestor fees from the transactions instead of manually
overriding.
2022-06-28 16:08:03 -05:00
Donald Adu-Poku
dfbd978579 multi: remove spend pruner.
Since the address index has been removed there is no longer a need for a spend
pruner component to keep track of spend  journal entries. This removes the
spend pruner components and its integrations.  DropConsumerDepsBucket has been
added to remove persisted spend pruner consumer dependencies which are now
unneeded.
2022-06-28 16:07:39 -05:00
Dave Collins
f0efcc2226
docker: Update image to golang:1.18.3-alpine3.16.
This updates the docker image to golang:1.18.3-alpine3.16.

To confirm the new digest:

$ docker pull golang:1.18.3-alpine3.16
...
1.18.3-alpine3.16: Pulling from library/golang
...
Digest: sha256:7cc62574fcf9c5fb87ad42a9789d5539a6a085971d58ee75dd2ee146cb8a8695
...
2022-06-17 13:44:50 -05:00
Sef Boukenken
c069a55198 mempool: Invert reorg transaction handling.
This commit inverts the order that transactions
are added to the mempool during a reorg so that
they are added in reverse block order.
2022-06-12 02:47:51 -05:00
Dave Collins
fb85522c58
blockchain: Return uint256 from chain work method.
This modifies the method that returns the total cumulative work for a
given block to return a more efficient uint256 instead of a big integer
and updates all consumers accordingly.
2022-06-10 13:33:21 -05:00
Dave Collins
1629418c7e
dcrd: 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.

Stated more plainly, this change means dcrd will now be shutdown cleanly
on more variants of unix as well as when being terminated by windows
itself due to various things such as the user logging off, the window
terminal being closed, and the system shutting down.
2022-06-10 13:02:41 -05:00
Dave Collins
891fc80de2
blockchain: Use new uint256 for work sums.
Live profiling data of performing an initial sync shows that roughly 36%
of all in-use allocations are the result of the big integers used to
store the cumulative work for each block. Further, around 12% of the
entire CPU time is spent scaning the heap for garbage collection which
is a direct result of the total number of inuse allocations.  Therefore,
a reasonable expectation is that eliminating those heap objects should
produce a speedup of around 4-5%.

Consequently, this modifies the blockchain package to make use of the
much more efficient zero-alloc uint256s and associated work calculation
funcs in the new primitives package that is under development.

Profiling shows the result is about 100MiB less heap usage on average
and a reduction of about 5% to the initial sync time which is in line
with the expected result.
2022-06-07 15:18:48 -05:00
Dave Collins
9f8114e53d
blockchain: Move package to internal.
The moves the blockchain package from the blockchain module to an
internal package of the root module meaning that it is no longer a part
of the exported blockchain module.  Nearly all of the logic it provides
is really for the internal implementation of dcrd itself and thus having
it exported module significantly increases the maintenance burden.

Note that as of this change the blockchain module still exists and
provides the chaingen and fullblocktests packages both or which are
useful and used by external consumers.

This is part of a continuing overall effort to reduce the total number
of exported packages and modules and eventually get to the point it will
be possible to follow semver for the root module.

Overview of the major changes:

- Move all go files from blockchain -> internal/blockchain
- Move testdata from blockchain -> internal/blockchain
- Remove doc.go in favor of the README.md since godoc now displays it
- Move README.md from blockchain -> internal/blockchain and update to
  match the new reality
- Add a new README.md in the exported blockchain module that documents
  it contains the remaining exported packages
- Update all import paths in the repository accordingly
- Run go mod tidy on all modules
2022-05-30 15:32:41 -05:00
Dave Collins
59a10331de
docs: Update chaingen readme module path. 2022-05-30 15:32:39 -05:00
Dave Collins
0ac1a5b588
mempool: Remove agendas from RemoveDoubleSpends.
This removes the treasury and auto revocations agenda flags from the
exported RemoveDoubleSpends method since they are no longer used.
2022-05-30 15:31:21 -05:00
Dave Collins
00eb633f95
mempool: Remove agendas from RemoveTransaction.
This removes the treasury and auto revocations agenda flags from the
exported RemoveTransaction method since they are no longer used.
2022-05-30 15:31:21 -05:00
Dave Collins
983943b7ce
mempool: Remove agendas from RemoveOrphansByTag.
This removes the treasury and auto revocations agenda flags from the
exported RemoveOrphansByTag method since they are no longer used.
2022-05-30 15:31:20 -05:00
Dave Collins
fdde83c23c
mempool: Remove agendas from RemoveOrphan.
This removes the treasury and auto revocations agenda flags from the
exported RemoveOrphan method since they are no longer used.
2022-05-30 15:31:20 -05:00
Dave Collins
2521b6c3df
mempool: Remove agendas from pruneExpiredTx.
This removes the treasury and auto revocations agenda flags from the
unexported pruneExpiredTx method since they are no longer used.
2022-05-30 15:31:20 -05:00
Dave Collins
604dac0bd9
mempool: Remove agenda from pruneStakeTx.
This removes the treasury agenda flag from the unexported pruneStakeTx
method since it is no longer used.
2022-05-30 15:31:19 -05:00
Dave Collins
e5138887cb
mempool: Remove agenda from addTransaction.
This removes the treasury agenda flag from the unexported addTransaction
method since it is no longer used.
2022-05-30 15:31:19 -05:00
Dave Collins
9b1b166010
mempool: Remove agendas from removeTransaction.
This removes the treasury and auto revocations agenda flags from the
unexported removeTransaction method since they are no longer used.
2022-05-30 15:31:18 -05:00
Dave Collins
ed0880ba6d
mempool: Remove removeOrphanDoubleSpends agendas.
This removes the treasury and auto revocations agenda flags from the
unexported removeOrphanDoubleSpends method since they are no longer
used.
2022-05-30 15:31:18 -05:00
Dave Collins
810839f66f
mempool: Remove agendas from maybeAddOrphan.
This removes the treasury and auto revocations agenda flags from the
unexported maybeAddOrphan method since they are no longer used.
2022-05-30 15:31:18 -05:00
Dave Collins
4becf579f6
mempool: Remove agendas from addOrphan.
This removes the treasury and auto revocations agenda flags from the
unexported addOrphan method since they are no longer used.
2022-05-30 15:31:17 -05:00
Dave Collins
e02c8a1d72
mempool: Remove agendas from limitNumOrphans.
This removes the treasury and auto revocations agenda flags from the
unexported limitNumOrphans method since they are no longer used.
2022-05-30 15:31:17 -05:00
Dave Collins
6b43d19df2
mempool: Remove agendas from removeOrphan.
This removes the treasury and auto revocations agenda flags from the
unexported removeOrphan method since they are no longer used.
2022-05-30 15:31:17 -05:00
Dave Collins
bba1ed89b9
blockchain: Implement header proof storage.
This modifies the chain logic to create and store the individual
commitment hashes covered by the commitment root field of the header of
each block and also adds code to migrate the database to retroactively
create and store entries for all applicable historical blocks.

The upgrade can be interrupted at any point and future invocations will
resume from the point it was interrupted.

The following is a high level overview of the changes:
- Introduce a new database bucket to house the header commitments
- Add serialization code for use when storing and loading the individual
  header commitment hashes
  - Add full test coverage for new serialization code
- Store the commitment hashes in the db when connecting blocks
- Implement database migration code to retroactively store the
  commitment hashes for all applicable historical blocks
  - Bump the chain database version to 13
  - Support resuming from interrupted upgrades
- Add a new func on the internal header commitment data struct that
  returns the v1 header commitment hashes to consolidate the logic
- Update FilterByBlockHash to load the header commitments from the db
  and generate the inclusion proof accordingly
2022-05-30 11:41:49 -05:00
Dave Collins
1d73a7f41f
blockchain: Avoid db for filters of unknown blocks.
This adds logic to avoid hitting the database when a compact filter that
can't possibly be available by first checking the block index to ensure
the requested block is both available and its data is known.
2022-05-30 11:41:48 -05:00
Dave Collins
b7e079e0a4
blockchain: Add filter hash to hdr cmt data struct.
This adds a field to the header commitment data struct to store the hash
of the filter along with the filter so that it can be reused without
needing to recalculate the hash.

starting
2022-05-30 11:41:48 -05:00
Dave Collins
3c42bae43f
blockchain: Correct some db cfilterv2 comments. 2022-05-30 11:41:44 -05:00
Dave Collins
b7676074e3
fullblocktests: Decouple from blockchain.
The blockchain/fullblocktests package currently has a cyclic dependency
on blockchain since the tests directly return the error codes in
blockchain that are expected to be violated while blockchain itself
needs to import the package in order to run the tests.

This resolves that cyclic dependency by defining all of the errors the
fullblocktests produce in the package itself and then converting them to
the associated error in blockchain when running the tests and checking
for the expected error.

It also moves the code that runs the fullblocktests into the blockchain
itself instead of a separate blockchain_test to match all other tests
now that there is no longer a cyclic dependency that forced it to be
be separated.

While duplication of the errors in question is a little less convenient,
this approach ensures the blockchain package can be made internal in the
future while still providing the publicly-available fullblocktests
package for use both in testing the internal blockchain implementation
as well as integration tests with other implementations.
2022-05-30 11:26:40 -05:00
Dave Collins
c49e7dc631
fullblocktests: Update readme module path. 2022-05-30 11:26:40 -05:00
Dave Collins
dd53b01842
blockchain: Rename error for no treasury payout.
This renames the error returned when there is no treasury payout present
in a coinbase and/or treasurybase to match its actual meaning.
2022-05-30 11:26:40 -05:00
Dave Collins
881312c916
blockchain: Remove unused difficulty error. 2022-05-30 11:26:39 -05:00
Dave Collins
d7d3372199
blockchain: Correct a few error comment typos. 2022-05-30 11:26:39 -05:00
Dave Collins
a4b20e9dd7
main: Only use server peer accessors.
This modifies the various peer callbacks in server to ignore the peer
parameter and only use the wrapped server peer as an accessor to ensure
consistent access.
2022-05-27 13:13:38 -05:00
Dave Collins
38fcd43a17
blockchain: Use standalone check tx sanity.
This modifies blockchain to make use of the recently-added
standalone.CheckTransactionSanity and remove its own version of it.
2022-05-27 12:56:04 -05:00
Dave Collins
0f26059d0a
standalone: Add transaction sanity check.
This adds a new exported function to the blockchain/standalone module
named CheckTransactionSanity which can be used to perform basic
transaction sanity checks.

It also updates the documentation and includes comprehensive tests.

The primary motivation for this change is that there are several
consumers that currently make use of this functionality and it lives in
the blockchain package which is slated to made internal and therefore
would otherwise become inaccessible to external consumers.

Another nice benefit of making this logic available via the
blockchain/standalone module is that it intentionally requires way less
dependencies which is ideal for consumers.
2022-05-27 12:39:06 -05:00
Dave Collins
af533c170a
rpc/jsonrpc/types: Remove getinfo addrindex field.
This removes the deprecated addrindex field from the getinforesult type.

This is part of the overall removal of the deprecated address index.
2022-05-19 17:08:07 -05:00
Dave Collins
55154501b7
rpcserver: Remove getinfo addrindex field.
This removes the deprecated getinfo method addrindex field from the
RPC server.

This is part of the overall removal of the deprecated address index.
2022-05-19 17:08:07 -05:00
Dave Collins
3c351a372b
docs: Update indexers readme for removed indexes. 2022-05-19 17:08:06 -05:00
Dave Collins
9618f1c118
docs: Update indexers readme module path. 2022-05-19 17:08:06 -05:00