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

[Bootstrap] Extracted rootblock and updated finalize #1371

Merged
merged 33 commits into from Oct 4, 2021

Conversation

durkmurder
Copy link
Member

dapperlabs/flow-go#5889
dapperlabs/flow-go#5891

Context

This PR implements rootblock command for bootstrap utility and updates finalize.

As result of rootblock we output DKG info and root block + votes into separate files.
finalize will consume public DKG data, root block and votes to construct QC and initialize collection clusters.

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

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

Thanks Yurii - looks good, had 2 main comments:

  1. We are losing DKG index information when converting between types. This will cause verification to fail.
  2. I added a suggestion to avoid needing to load a private key to aggregate the QC. This is not strictly a blocker, but I think it's worth removing the unneeded flag and logic.

cmd/bootstrap/cmd/dkg.go Outdated Show resolved Hide resolved
cmd/bootstrap/cmd/constraints.go Outdated Show resolved Hide resolved
cmd/bootstrap/cmd/seal.go Outdated Show resolved Hide resolved
cmd/bootstrap/cmd/finalize.go Outdated Show resolved Hide resolved
cmd/bootstrap/cmd/finalize.go Show resolved Hide resolved
cmd/bootstrap/cmd/finalize.go Outdated Show resolved Hide resolved
cmd/bootstrap/cmd/finalize_test.go Outdated Show resolved Hide resolved

// GenerateQCSignerParticipantData generates participant data for creating QC.
// Caller needs to pass dkg participants that will be taking part in building QC.
func GenerateQCSignerParticipantData(internalNodes []bootstrap.NodeInfo, dkgParticipant dkg.DKGParticipantPriv, dkgData inmem.EncodableDKG) (*ParticipantData, error) {
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned in the other comment, we don't actually need a private key to generate a QC from existing votes.

I wrote up a function that should do the trick to generate a signer/validator which can be used, without needing to load any private data (which ultimately isn't used anyway):

func createAggregator(participantData *ParticipantData) (hotstuff.Validator, hotstuff.SignerVerifier, error) {

	identities := participantData.Identities()

	var (
		unusedLocalNodeID                   = flow.ZeroID
		unusedModuleLocal module.Local      = nil
		unusedPrivateKey  crypto.PrivateKey = nil
	)

	// create consensus committee's state
	committee, err := committees.NewStaticCommittee(identities, unusedLocalNodeID, participantData.Lookup, participantData.GroupKey)
	if err != nil {
		return nil, nil, err
	}

	merger := signature.NewCombiner(encodable.ConsensusVoteSigLen, encodable.RandomBeaconSigLen)
	stakingSigner := signature.NewAggregationProvider(encoding.ConsensusVoteTag, unusedModuleLocal)
	beaconVerifier := signature.NewThresholdVerifier(encoding.RandomBeaconTag)
	beaconSigner := signature.NewThresholdProvider(encoding.RandomBeaconTag, unusedPrivateKey)
	beaconStore := signature.NewSingleSignerStore(beaconSigner)
	signer := verification.NewCombinedSigner(committee, stakingSigner, beaconVerifier, merger, beaconStore, flow.ZeroID)

	validator := validator.New(committee, new(mocks.ForksReader), signer)

	return validator, signer, nil
}

cmd/bootstrap/cmd/constraints.go Outdated Show resolved Hide resolved
cmd/bootstrap/cmd/constraints.go Outdated Show resolved Hide resolved
Copy link
Member

@AlexHentschel AlexHentschel left a comment

Choose a reason for hiding this comment

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

Looks good to me

cmd/bootstrap/cmd/finalize.go Outdated Show resolved Hide resolved
cmd/bootstrap/run/qc.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2021

Codecov Report

Merging #1371 (2476f96) into master (c40cfbc) will increase coverage by 0.07%.
The diff coverage is 75.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1371      +/-   ##
==========================================
+ Coverage   56.36%   56.44%   +0.07%     
==========================================
  Files         504      505       +1     
  Lines       31210    31332     +122     
==========================================
+ Hits        17593    17684      +91     
- Misses      11247    11271      +24     
- Partials     2370     2377       +7     
Flag Coverage Δ
unittests 56.44% <75.77%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/bootstrap/cmd/final_list.go 8.40% <0.00%> (ø)
cmd/bootstrap/utils/file.go 0.00% <0.00%> (ø)
cmd/bootstrap/cmd/qc.go 50.00% <60.00%> (+7.14%) ⬆️
cmd/bootstrap/run/qc.go 46.05% <71.42%> (+2.57%) ⬆️
cmd/bootstrap/cmd/finalize.go 65.43% <76.08%> (+0.12%) ⬆️
cmd/bootstrap/cmd/rootblock.go 94.82% <94.82%> (ø)
cmd/bootstrap/cmd/constraints.go 54.54% <100.00%> (+5.82%) ⬆️
cmd/bootstrap/cmd/dkg.go 87.09% <100.00%> (+7.09%) ⬆️
consensus/hotstuff/event_loop.go 52.00% <0.00%> (-2.67%) ⬇️
admin/command_runner.go 80.00% <0.00%> (ø)

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 c40cfbc...2476f96. Read the comment docs.

Copy link
Member

@AlexHentschel AlexHentschel left a comment

Choose a reason for hiding this comment

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

🎉

jordanschalm added a commit that referenced this pull request Sep 29, 2021
@AlexHentschel AlexHentschel merged commit a4d6955 into master Oct 4, 2021
@AlexHentschel AlexHentschel deleted the yurii/5891-update-finalize branch October 4, 2021 20:30
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

6 participants