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

dkg: exchange sigTypes concurrently #2496

Merged
merged 4 commits into from
Aug 2, 2023
Merged

Conversation

gsora
Copy link
Collaborator

@gsora gsora commented Aug 1, 2023

Before this commit, calling exchange() would listen for new incoming messages and discard everything that didn't carry the expected sigType.

In a DKG one node might fall behind the others (for example, while DKG'ing 3000 validator keys) and send sigTypes that the other peers have already received threshold for.

This PR makes sure a given instance of exchanger will hold onto all messages whose sigTypes are specified during its initialization phase.

Calling exchange() will return as soon as there are enough messages for the specified sigType, but different sigTypes messages will still be stored and will be returned when requested by means of another exchange() call, with a different sigType argument.

category: bug
ticket: #2491

Closes #2491.

Before this commit, calling `exchange()` would listen for new incoming messages and discard everything that didn't carry the expected sigType.

In a DKG one node might fall behind the others (for example, while DKG'ing 3000 validator keys) and send sigTypes that the other peers have already received threshold for.

This commit makes sure a given instance of `exchanger` will hold onto all messages whose sigTypes are specified during its initialization phase.

Calling `exchange()` will return as soon as there are enough messages for the specified sigType, but different sigTypes messages will still be stored and will be returned when requested by means of another `exchange()` call, with a different sigType argument.
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Patch coverage: 96.42% and project coverage change: +0.18% 🎉

Comparison is base (4f0d8ba) 53.52% compared to head (0fac116) 53.70%.
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2496      +/-   ##
==========================================
+ Coverage   53.52%   53.70%   +0.18%     
==========================================
  Files         198      199       +1     
  Lines       26757    26813      +56     
==========================================
+ Hits        14321    14400      +79     
+ Misses      10648    10626      -22     
+ Partials     1788     1787       -1     
Files Changed Coverage Δ
dkg/exchanger.go 87.95% <96.07%> (+7.55%) ⬆️
dkg/dkg.go 58.29% <100.00%> (+0.23%) ⬆️

... and 19 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

dkg/exchanger.go Outdated Show resolved Hide resolved
dkg/exchanger.go Outdated Show resolved Hide resolved
dkg/exchanger.go Show resolved Hide resolved
}

// set sets data for the given sigType and core.PubKey.
func (stb *dataByPubkey) set(pubKey core.PubKey, sigType sigType, data []core.ParSignedData) {
Copy link
Contributor

@corverroos corverroos Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can refactor this to take a single sigdata parameter

type sigTypeStore map[sigType]map[core.PubKey][]core.ParSignedData

// dataByPubkey maps a sigType to its map of public key to slice of core.ParSignedData..
type dataByPubkey struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personal style: I would not introduce more types. I would just put the lock and a map[sigType]sigData in exchanger itself.

func (e exchanger) set(sigdata) {...}
func (e exchanger) get(sigtype) (sigdata, bool) {...}

But that is just me #lessismore

@corverroos
Copy link
Contributor

LGTM

@gsora gsora self-assigned this Aug 2, 2023
@gsora gsora added the merge when ready Indicates bulldozer bot may merge when all checks pass label Aug 2, 2023
@obol-bulldozer obol-bulldozer bot merged commit 7371573 into main Aug 2, 2023
12 checks passed
@obol-bulldozer obol-bulldozer bot deleted the gsora/async_dkg_exchanger branch August 2, 2023 10:19
gsora added a commit that referenced this pull request Aug 9, 2023
Before this commit, calling `exchange()` would listen for new incoming messages and discard everything that didn't carry the expected `sigType`.

In a DKG one node might fall behind the others (for example, while DKG'ing 3000 validator keys) and send `sigTypes` that the other peers have already received threshold for.

This PR makes sure a given instance of `exchanger` will hold onto all messages whose `sigTypes` are specified during its initialization phase.

Calling `exchange()` will return as soon as there are enough messages for the specified `sigType`, but different `sigType`s messages will still be stored and will be returned when requested by means of another `exchange()` call, with a different `sigType` argument.

category: bug
ticket: #2491

Closes #2491.
obol-bulldozer bot pushed a commit that referenced this pull request Aug 9, 2023
The following PRs have been cherry-picked:

- #2490
- #2494
- #2496
- #2509
- #2510
- #2504
- #2511
- #2514
- #2516
- #2518


category: misc
ticket: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible race condition in DKG exchanger
2 participants