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: add aggregate lock hash signing skeleton #518

Merged
merged 3 commits into from
May 13, 2022
Merged

Conversation

corverroos
Copy link
Contributor

Adds the general steps to create an aggregate signature of the lock hash by all validators.

category: feature
ticket: #478

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #518 (50e708e) into main (6aeb6eb) will decrease coverage by 0.39%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #518      +/-   ##
==========================================
- Coverage   55.46%   55.06%   -0.40%     
==========================================
  Files          90       90              
  Lines        8366     8408      +42     
==========================================
- Hits         4640     4630      -10     
- Misses       3118     3173      +55     
+ Partials      608      605       -3     
Impacted Files Coverage Δ
dkg/dkg.go 48.86% <0.00%> (-14.12%) ⬇️
tbls/tss.go 49.07% <0.00%> (-0.61%) ⬇️
core/aggsigdb/memory.go 86.17% <0.00%> (-2.13%) ⬇️
app/app.go 63.90% <0.00%> (-1.19%) ⬇️
core/qbft/qbft.go 86.16% <0.00%> (+0.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6aeb6eb...50e708e. Read the comment docs.

dkg/dkg.go Outdated
Comment on lines 206 to 210
db := parsigdb.NewMemDB(lock.Threshold)
exchange := parsigex.NewParSigEx(tcpNode, peerIdx, peers)
db.SubscribeInternal(exchange.Broadcast)
db.SubscribeThreshold(makeSigAgg(sigChan))
exchange.Subscribe(db.StoreExternal)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

using core workflow components for all the heavy lifting.

Note that the generic way these components have been implemented, allows them to be used in a different use-case here in DKG.

Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we desubscribe when the function finishes, or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is the select function below

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand, which line?

Copy link
Contributor Author

@corverroos corverroos May 12, 2022

Choose a reason for hiding this comment

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

these methods only wires stuff

the input is:

	err = db.StoreInternal(ctx, core.Duty{}, signedSet)
	if err != nil {
		return nil, err
	}

the output is below at:

		    case sig := <-sigChan:
			sigs = append(sigs, sig)
		}
		if len(sigs) == len(lock.Validators) {
			break
		}

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah that's right, there's no need to unsubscribe. So basically in charon we follow functional programming paradigm where we keep our functions/methods to be stateless and only introduce statefulness whenever necessary. We don't need unsubscription because we aren't persisting anything. So when that function goes out of scope, we are done. Go's GC will take care of that.
On the other hand, we introduce statefulness for functions mainly by returning functions i.e, closures.

Am I right, @corverroos ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

exactly right! 🚀

Copy link
Contributor

Choose a reason for hiding this comment

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

@dB2510 @corverroos
| we keep our functions/methods to be stateless and only introduce statefulness whenever necessary

This is very good, a good practice, but not linked to functional programming, this is done in OOP and any style of programming.

@dB2510 @corverroos

I see now that we are creating our own parsigdb and exchange every time we call this function, and that is the reason the subscribers are garbage collected. I didn't catch that before.

Is this intended for some reason? or just a temporary shortcut that will be refactored in the future?

Just asking...

Copy link
Contributor

@dB2510 dB2510 May 13, 2022

Choose a reason for hiding this comment

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

Is this intended for some reason? or just a temporary shortcut that will be refactored in the future?

yes, this is temporary. You can refer here for next steps: #522

Copy link
Contributor

Choose a reason for hiding this comment

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

ok 👍

// TODO(corver): Implement lock hash signing by all DVs and aggregation.
// aggSignLockHash returns the aggregated multi signature of the lock hash
// signed by all the distributed validator group private keys.
func aggSignLockHash(ctx context.Context, tcpNode host.Host, peerIdx int,
Copy link
Contributor

Choose a reason for hiding this comment

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

@corverroos please, either one line or each parameter on its own line. I think that is how I always saw it. Isn't a linter for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

at this point this isn't linted or specified anywhere

Copy link
Contributor

@dB2510 dB2510 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +207 to +212
sigChan := make(chan *bls_sig.Signature, len(lock.Validators))
sigdb := parsigdb.NewMemDB(lock.Threshold)
exchange := parsigex.NewParSigEx(tcpNode, peerIdx, peers)
sigdb.SubscribeInternal(exchange.Broadcast)
sigdb.SubscribeThreshold(makeSigAgg(sigChan))
exchange.Subscribe(sigdb.StoreExternal)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add comments for these lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure will do in next PR

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label May 13, 2022
@obol-bulldozer obol-bulldozer bot merged commit 8236459 into main May 13, 2022
@obol-bulldozer obol-bulldozer bot deleted the corver/dkgsign branch May 13, 2022 07:30
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.

3 participants