Commit Graph

6670 Commits

Author SHA1 Message Date
SeedHammer
0d633fcd00
secp256k1: add support for resource constrained environments (TinyGo)
Some checks failed
Build and Test / Go CI (1.21) (push) Has been cancelled
Build and Test / Go CI (1.22) (push) Has been cancelled
The pre-computed table for speeding up ScalarBaseMultNonConst is
several hundred kilobytes in the binary and even more when unpacked
into working memory. Special-case ScalarBaseMultNonConst to fall back to
ScalarMultNonConst when the 'tinygo' tag is specified, which is true
when building a Go program with TinyGo.
2024-03-19 16:05:24 +00:00
Dave Collins
c6322d513a
docker: Update image to golang:1.22.1-alpine3.19.
This updates the docker image to golang:1.22.1-alpine3.19.

To confirm the new digest:

```
$ docker pull golang:1.22.1-alpine3.19
1.22.1-alpine3.19: Pulling from library/golang
...
Digest: sha256:fc5e5848529786cf1136563452b33d713d5c60b2c787f6b2a077fa6eeefd9114
...
```
2024-03-11 17:35:50 -05:00
David Hill
20dedca001
server: Update required minimum protocol version.
This updates the required minimum protocol version to the maximum
set by dcrwallet 1.8.0.  Outbound connections will require the
current protocol version.
2024-02-19 17:38:20 -06:00
Dave Collins
eb3de8e729
docs: Update README.md to required Go 1.21/1.22. 2024-02-09 13:39:47 -06:00
Dave Collins
fedbaf982b
build: Test against Go 1.22.
This updates CI to test against Go 1.22 and removes the tests for Go
1.20 accordingly.
2024-02-09 13:39:47 -06:00
Dave Collins
db71f88b36
build: Update golangci-lint to v1.56.0. 2024-02-09 13:39:43 -06:00
Dave Collins
af2e9b8550
docker: Update image to golang:1.22.0-alpine3.19.
This updates the docker image to golang:1.22.0-alpine3.19.

To confirm the new digest:

```
$ docker pull golang:1.22.0-alpine3.19
1.22.0-alpine3.19: Pulling from library/golang
...
Digest: sha256:8e96e6cff6a388c2f70f5f662b64120941fcd7d4b89d62fec87520323a316bd9
...
```
2024-02-07 10:53:02 -06:00
Dave Collins
aa29074059
main: Update license to 2024. 2024-02-07 10:50:28 -06:00
Dave Collins
627e64f4af
build: Update golangci-lint to v1.55.2. 2024-01-10 09:19:24 -06:00
Dave Collins
f4398374aa
build: Update to latest action versions.
This updates to the following Github Actions:

- actions/checkout@b4ffde65f4 #v4.1.1
- actions/setup-go@0c52d547c9 #v5.0.0
- actions/cache@704facf57e # v3.3.2
2024-01-10 09:17:35 -06:00
Dave Collins
35215535f4
docker: Update image to golang:1.21.6-alpine3.19.
This updates the docker image to golang:1.21.6-alpine3.19.

To confirm the new digest:

```
$ docker pull golang:1.21.6-alpine3.19
1.21.6-alpine3.19: Pulling from library/golang
...
Digest: sha256:fd78f2fb1e49bcf343079bbbb851c936a18fc694df993cbddaa24ace0cc724c5
...
```
2024-01-09 20:41:04 -06:00
Dave Collins
fac4c14dbb
wire: Mark legacy message types as deprecated.
This marks the various messages types and commands associated with
version 1 cfilters as deprecated since they are no longer valid and will
eventually be removed whenever a new major version of the wire module is
released..
2023-12-20 15:37:22 -06:00
Dave Collins
7521c81182
docker: Update image to golang:1.21.5-alpine3.18.
This updates the docker image to golang:1.21.5-alpine3.18.

To confirm the new digest:

```
$ docker pull golang:1.21.5-alpine3.18
1.21.5-alpine3.18: Pulling from library/golang
...
Digest: sha256:5c1cabd9a3c6851a3e18735a2c133fbd8f67fe37eb3203318b7af2ffd2547095
...
```
2023-12-05 19:53:38 -06:00
Josh Rickmar
3df2b50a90 peer: provide better debug for queued nil messages
If the doneChan is nil, the nil message can be safely ignored.  However, this
is still a bug in the caller, so a warning with stacktrace is logged.

If the doneChan is non-nil, panicing is the only reasonable option to prevent
the program continuing on in an unknown state.

The peer code would already panic previously in wire.WriteMessageN for many
queued message types, and introducing a new panic call here should not
introduce any new crashes that would not have occurred before.
2023-11-13 10:47:44 -06:00
Dave Collins
c077ac82c7
docker: Update image to golang:1.21.4-alpine3.18.
This updates the docker image to golang:1.21.4-alpine3.18.

To confirm the new digest:

```
$ docker pull golang:1.21.4-alpine3.18
1.21.4-alpine3.18: Pulling from library/golang
...
Digest: sha256:110b07af87238fbdc5f1df52b00927cf58ce3de358eeeb1854f10a8b5e5e1411
...
```
2023-11-10 13:15:46 -06:00
Josh Rickmar
bcc0db1189 peer: select on p.quit during stall control chan writes
Hangs at peer disconnect were observed due to the blocking writes on the
buffered stall control channel.  This is a new bug that was introduced after
the recent queuing changes that allow more messages to be read at a time.
2023-11-07 14:48:13 -06:00
Dave Collins
c1e4cdd9e7
server: Don't wait or try to send notfound data.
This modifies the recent concurrent getdata serving logic to immediately
decrement the pending item count and move on to the next requested data
item when an item is not found.

Not only is it more efficient since it means there is no attempt to
acquire the semaphore, it also prevents an issue the new code introduced
where it could incorrectly queue up a nil message leading to a panic.
2023-10-31 13:16:19 -05:00
Dave Collins
3aaaf3f232
server: Support concurrent getdata requests.
Currently, each peer only supports one getdata request at a time and the
inbound handler is blocked until all of the requested data is served.
This means messages that would otherwise be fast to process, such as
pings, can potentially be delayed for long periods of time which is
clearly not ideal.

Moreover, the existing behavior means that it is theoretically possible
for a pair of peers to experience a situation where neither one can make
progress because they're both waiting on each other to serve each other
data which then would ultimately result in hitting idle timeouts and
disconnection.

In practice, the aforementioned live lock situation basically never
happens currently due to a variety of other factors such as duplicate
request filtering and not notifying peers about inventory they are known
to have.  However, the combination of factors that prevent the situation
will not necessarily apply to newer data types such as those for
mesh-based mixing.

The aforementioned blocking behavior is a holdover from very early
network code that relied on it once upon a time, but is no longer
relevant.

Thus, to improve overall throughput and address the root of the
aforementioned concerns, this changes the semantics to serve getdata
requests asynchronously so other inbound messages can be processed
concurrently.  This means the remote peer is then free to send other
messages while waiting for the requested data to be served.

Next, limits to the amount of concurrent getdata requests and the total
maximum number of pending individual data item requests are now imposed
in order to prevent peers from be able to consume copious amounts of
memory and other malicious behavior this change would otherwise allow.

The limits are enforced such that peers may now mix and match
simultaneous getdata requests for varying amounts of data items so long
as they do not exceed the maximum number of allowed simultaneous pending
getdata messages or the maximum number of total overall pending
individual data item requests.

This approach of applying the limits on both dimensions offers more
flexibility and the potential for future efficiency gains while still
keeping memory usage bounded to reasonable limits and protecting against
other malicious behavior.
2023-10-30 11:16:07 -05:00
Dave Collins
b60de607b5
server: Use server peer in log statements.
This change a few cases that log the peer to use the server peer instead
of the underlying peer from the peer package.  This doesn't change the
output in any way, but it is more consistent with the vast majority of
other instances.  It also preferable since it ensures consistent logging
output if a custom stringer is ever implemented on server peers.
2023-10-28 13:09:24 -05:00
Dave Collins
517091c7f6
netsync: Export opaque peer and require it in API.
Currently the sync manager maintains additional state per peer in an
internal struct that wraps a base/common peer as well as a mapping keyed
by that base/common peer.  The internal wrapped peer is then queried
each time it is needed.  This leads to code that is harder to reason
about and can fail to lookup the necessary state in some hard to hit
corner cases.

With that in mind, this modifies the sync manager semantics to instead
export the wrapped peer and require the caller to provide that wrapped
peer in all of its APIs directly.  The server then creates and stores
the wrapped peer instance at connection time and passes it to the sync
manager.

The end result is the code is easier to reason about and resolves the
aforementioned hard to hit corner cases since it is no longer possible
for the sync manager to ever have access to a peer without the
associated extra state.
2023-10-28 01:51:49 -05:00
Dave Collins
a3698da32d
netsync: Rename DonePeer to PeerDisconnected.
This renames the DonePeer method to PeerDisconnected to more clearly
denote its purpose.  It also renames some of the internal plumbing to
match.
2023-10-28 01:51:49 -05:00
Dave Collins
00641815e1
netsync: Rename NewPeer to PeerConnected.
This renames the NewPeer method to PeerConnected to more clearly denote
its purpose.  It also renames some of the internal plumbing to match.
2023-10-28 01:51:49 -05:00
Dave Collins
4e3263c0d9
multi: Consolidate waitgroup logic.
This switches the various subsystems over to use a new pattern that
consolidates the waitgroup logic in a single location.

This pattern is easier to reason about and less error prone since it's
trivial to see at a glance that the calls to Done are happening as
intended versus having to chase them down all over the code.
2023-10-28 01:48:52 -05:00
Dave Collins
ae64e5164f
multi: Reduce done goroutines.
This modifies the logic in several Run methods to block until the
context is cancelled directly in the Run method instead of launching a
separate goroutine for that purpose.

This approach is preferred since it provides the same functionality
without additional long-running goroutines.
2023-10-25 09:58:31 -05:00
Dave Collins
672c3458fb
docker: Update image to golang:1.21.3-alpine3.18.
This updates the docker image to golang:1.21.3-alpine3.18.

To confirm the new digest:

```
$ docker pull golang:1.21.3-alpine3.18
1.21.3-alpine3.18: Pulling from library/golang
...
Digest: sha256:926f7f7e1ab8509b4e91d5ec6d5916ebb45155b0c8920291ba9f361d65385806
...
```
2023-10-12 17:02:43 -05:00
Dave Collins
75147d231e
docker: Update image to golang:1.21.2-alpine3.18.
This updates the docker image to golang:1.21.2-alpine3.18.

To confirm the new digest:

```
$ docker pull golang:1.21.2-alpine3.18
1.21.2-alpine3.18: Pulling from library/golang
...
Digest: sha256:a5d901a53f906be8dd00c6274ffce633b1873a144dd17c6e8293745695740f07
...
```
2023-10-08 23:02:32 -05:00
Dave Collins
fcae044a5f
docs: Add release notes for v1.8.1. 2023-10-08 23:01:00 -05:00
peterzen
c102e54b41
dcrutil: Use os.UserHomeDir in appDataDir.
Obtain user home directory from os.UserHomeDir() instead of
user.Current().HomeDir.
2023-10-04 19:08:13 -05:00
Dave Collins
dc41075594
secp256k1/ecdsa: Add test for order wraparound.
Since it is impossible to calculate the necessary values without
breaking the ECDLP, this adds an invented signature to exercise the
branch of the RecoverCompact function that involves the case when the
original X coordinate of the random point is greater than the group
order and therefore has the overflow bit set.

The result is raising the test coverage from 99.2% to 99.6%.
2023-09-21 11:44:54 -05:00
Dave Collins
9754217aff
secp256k1/ecdsa: Add tests for new R and S methods.
This adds a couple of additional checks to the sign and verify tests to
ensure the new R and S methods return the expected values.
2023-09-21 11:42:30 -05:00
Dave Collins
813446bf0e
secp256k1/ecdsa: Remove some unnecessary subslices.
This updates the tests to avoid slicing things that are already a slice.
2023-09-21 11:40:30 -05:00
Dave Collins
87adb31f4b
main: Add read header timeout to profile server.
The profiling server typically shouldn't be exposed to the public, so
this doesn't make a huge difference, but it's still good practice for
HTTP servers to have read timeouts.
2023-09-21 11:27:27 -05:00
Billy Zaelani Malik
2daf6c9c24 secp256k1/ecdsa: Expose r and s value of signature. 2023-09-21 00:18:05 -05:00
Dave Collins
a20782d6a4
sampleconfig: Use embed with external files.
This updates the sampleconfig package to make use of Go's embed
functionality introduced in Go 1.16 which is acceptable since the
containing module requires Go 1.19.

Embedded files are preferable because they bring the benefits of both
external files in the repository that are easier to work with for
external tools and the ability to access their content programmatically
without having to deal with the various issues typically brought about
by programmatically accessing external files.

Also, when this was last updated to change the exported variable for
dcrd's sample config file over to a function (so it can't be mutated and
the implementation details can be changed if needed), the case for
dcrctl was missed.  Moreover, the existence of both configs makes the
func name FileContents ambiguous.

Unfortunately, those things can't be changed now without causing a major
module version bump to the main dcrd module which we really want to
avoid.

So, in order to address those things without needing a major module
version bump, this deprecates the FileContents func and
DcrctlSampleConfig variable and introduces two new functions named Dcrd
and Dcrctl that return the respective embedded sample configs.
2023-09-18 03:32:50 -05:00
Dave Collins
5204b35a33
rpcserver: Improve internal error handling.
This cleans up the handling of internal errors in the RPC server to be
more consistent and use the errors themselves as opposed to their
stringized form.

There are far more instances of already having an error to pass along
versus the ones that generate new errors at the call site.  Accepting
the errors directly results in less noise and also makes it harder to
misuse.
2023-09-08 20:42:17 -05:00
Dave Collins
8de37df04a
docker: Update image to golang:1.21.1-alpine3.18.
This updates the docker image to golang:1.21.1-alpine3.18.

To confirm the new digest:

```
$ docker pull golang:1.21.1-alpine3.18
1.21.1-alpine3.18: Pulling from library/golang
...
Digest: sha256:96634e55b363cb93d39f78fb18aa64abc7f96d372c176660d7b8b6118939d97b
...
```
2023-09-08 20:35:45 -05:00
Dave Collins
ad96f2cf6c
rpcserver: Modify getnetworkhashps -1 blocks logic.
Now that the target difficulty is calculated every block as opposed to
on an interval, the logic in the getnetworkhashps RPC that treated a
negative number of blocks as a signal to calculate back to the most
recent difficulty change no longer makes sense.

Thus, this updates the getnetworkhashps RPC to ignore negative values
so that the default number of blocks is used instead.

It also updates the RPC server help description accordingly to remove
mention of the previous behavior.
2023-09-02 22:15:43 -05:00
Dave Collins
f69247ff24
build: Add errorlint linter.
This adds the errorlint linter to the list of linters and addresses a
few false positives it complains about.
2023-08-28 14:53:30 -05:00
Dave Collins
318d81bc90
multi: Wrap errors for better errors.Is/As support.
This updates all remaining cases of unwrapped errors in fmt.Errorf calls
to wrap the underlying errors with the %w format verb to ensure they
work nicely with errors.Is and errors.As.
2023-08-25 16:31:11 -05:00
Dave Collins
ba7e40fa4d
blockchain: Remove unused trsy enabled param.
This removes the isTreasuryEnabled paramter from the blockchain
getStakeBaseAmounts func since it is no longer used and updates the only
caller accordingly.
2023-08-25 12:41:22 -05:00
Dave Collins
5365a7be8a
blockchain: Remove unused progress logger param.
This removes the parent paramter from the LogBlockHeight method on
the internal blockchain progress logger since it is no longer used and
updates all callers accordingly.
2023-08-25 12:41:22 -05:00
Dave Collins
3e2ccdc6c8
multi: Cleanup superfluous trailing newlines. 2023-08-25 12:39:15 -05:00
Dave Collins
70b399c9e4
build: Add dupword linter.
This adds the dupword linter to the list of linters and addresses a few
false positives it complains about.
2023-08-25 12:35:55 -05:00
Dave Collins
fc54d98b1e
multi: Remove a bunch of dup words in comments. 2023-08-23 14:13:51 -05:00
Dave Collins
0a35adc021
standalone: Add decreasing timestamps ASERT test.
This adds another scenario to the ASERT test vectors to ensure the
expected behavior with decreasing timestamps.
2023-08-20 23:54:06 -05:00
Dave Collins
4f00f59360
docs: Update README.md to required Go 1.20/1.21. 2023-08-18 12:33:56 -05:00
Dave Collins
d5819dfedf
build: Test against Go 1.21.
This updates CI to test against Go 1.21 and removes the tests for Go
1.19 accordingly.
2023-08-18 12:33:04 -05:00
Dave Collins
cb4755d43b
build: Update golangci-lint to v1.53.1. 2023-08-18 12:32:37 -05:00
Dave Collins
023c2605e9
build: Update to latest action versions.
This updates to the following Github Actions:

- actions/setup-go@93397bea11 # v4.1.0
2023-08-18 12:31:25 -05:00
Dave Collins
4f83c718e1
docker: Update image to golang:1.21.0-alpine3.18.
This updates the docker image to golang:1.21.0-alpine3.18.

To confirm the new digest:

```
$ docker pull golang:1.21.0-alpine3.18
...
1.21.0-alpine3.18: Pulling from library/golang
...
Digest: sha256:445f34008a77b0b98bf1821bf7ef5e37bb63cc42d22ee7c21cc17041070d134f
...
```
2023-08-09 04:00:55 -05:00