Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-v2.0] main: Use backported mixing updates. #3391

Merged
merged 9 commits into from
Jun 19, 2024

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jun 19, 2024

This updates the 2.0 release branch to use the latest version of the mixing module which includes updates to improve sender privacy through the use of randomized broadcasts and increase performance.

In particular, the following updated module version is used:

  • github.com/decred/dcrd/mixing@v0.4.0

Note that it also cherry picks all of the commits included in updates to the mixing module to ensure they are also included in the release branch even though it is not strictly necessary since go.mod has been updated to require the new release and thus will pull in the new code. However, from past experience, not having code backported to modules available in the release branch too leads to headaches for devs building from source in their local workspace with overrides such as those in go.work.

The buffers written to during signature creation and validation have a known
constant size.  Preallocate these buffers to reduce the total number of
allocations that are needed as fmt.Sprintf writes to the buffer.
The number of expected messages can be determined by the capacity of the
intended message type's slice.
@davecgh davecgh added this to the 2.0.3 milestone Jun 19, 2024
davecgh and others added 7 commits June 19, 2024 16:08
This updates the mixing module to use dcrd/crypto/rand for key
and uniform random big integer generation.
Runs are always required to be zero now.
This significantly reduces the number of allocations needed to create a
vector of exponential DC-net pads by reusing a digest slice prior to
converting the result to a big integer.

Specifically, it reduces the allocations for the digest calculation from
quadratic in the number of participants to a single alloc.  The big
integers themselves are still predominantly linear in the number of
participants, however, that they are not entirely linear because the big
ints involve multiple allocations as the numbers grow larger prior to
the modular reduction.

For a concrete example, with 15 participants, the total number of
overall allocations with this change is reduced from 257 down to 47.
This adds a cache to house mix messages that have recently been removed
from the mixpool.  It makes use of the new container/lru module to
handle automatic expiration of entries and maximum entry limiting.

The rationale for this change is that it is considered misbehavior to
advertise a mix message and then claim it is not found when the
corresponding request arrives.  Maintaining a separate cache of mix
messages recently removed from the mixpool for a short period of time
significantly increases the probability they are available to serve when
a request for the advertisement arrives independent of the current
status of the mixpool.
In this change, random per-peer (per-identity) and per-message jitter are
added to add additional delay to all message broadcasts.  The jitter delay
will range from 0-3s, with a random 0-2700ms of that being per-peer and
0-300ms being per-message.  The total delay is calculated as 1/10 of the stage
timeout duration, and the per-message delay is calculated is both the mean and
median of dcrd's inventory trickling delay.

While here, pair request messages are also submitted to the network with
random delays spanning over the entire epoch duration, while avoiding any PR
sends during the 30s before and after the epoch.
This updates the 2.0 release branch to use the latest version of the
mixing module which includes updates to improve sender privacy through
the use of randomized broadcasts and increase performance.

In particular, the following updated module version is used:

- github.com/decred/dcrd/mixing@v0.4.0
@davecgh davecgh merged commit 70cd1bf into decred:release-v2.0 Jun 19, 2024
2 checks passed
@davecgh davecgh deleted the rel20_mixing_backports branch June 19, 2024 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants