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

cmd: clean up create cluster deposit data #561

Merged
merged 3 commits into from
May 19, 2022
Merged

Conversation

corverroos
Copy link
Contributor

Small cleanups of deposit data integration in create cluster.

category: refactor
ticket: #549

@codecov
Copy link

codecov bot commented May 19, 2022

Codecov Report

Merging #561 (e07e71a) into main (82e1bfa) will decrease coverage by 0.58%.
The diff coverage is 64.44%.

@@            Coverage Diff             @@
##             main     #561      +/-   ##
==========================================
- Coverage   55.26%   54.67%   -0.59%     
==========================================
  Files          92       92              
  Lines        8675     8664      -11     
==========================================
- Hits         4794     4737      -57     
- Misses       3241     3287      +46     
  Partials      640      640              
Impacted Files Coverage Δ
cmd/createcluster.go 52.97% <54.28%> (-2.24%) ⬇️
eth2util/deposit/deposit.go 59.64% <100.00%> (+1.09%) ⬆️
core/qbft/qbft.go 72.11% <0.00%> (-9.59%) ⬇️

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 82e1bfa...e07e71a. Read the comment docs.

@@ -94,7 +94,6 @@ type clusterConfig struct {
Clean bool

NumNodes int
NumDVs int
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not used

@@ -168,6 +167,10 @@ func runCreateCluster(w io.Writer, conf clusterConfig) error {
}
}

if err := validateClusterConfig(conf); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fail fast: do validation at the start

}

if err = writeDepositData(conf, pubkeys, msgSigs, conf.WithdrawalAddr, conf.Network); err != nil {
if err = writeDepositData(conf, secrets); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do all deposit data stuff in one place

var pubkeys []eth2p0.BLSPubKey
var msgSigs []eth2p0.BLSSignature
// signDepositDatas returns a map of deposit data signatures by DV pubkey.
func signDepositDatas(secrets []*bls_sig.SecretKey, withdrawalAddr string, network string) (map[eth2p0.BLSPubKey]eth2p0.BLSSignature, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

instead of two slices that are implicitly linked, explicitly link pubkeys and signatures in a single map

Copy link
Contributor

Choose a reason for hiding this comment

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

noted! is this the preferred approach?


for i := 0; i < numDVs; i++ {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use secrets directly (instead of another variable)

return nil, nil, err
}

withdrawalAddr, err := checksumAddr(addr)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this only needs to be done once

@@ -105,6 +106,10 @@ func MarshalDepositData(pubkeys []eth2p0.BLSPubKey, msgSigs []eth2p0.BLSSignatur
})
}

sort.Slice(ddList, func(i, j int) bool {
return ddList[i].PubKey < ddList[j].PubKey
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make output deterministic

@@ -1,4 +1,15 @@
[
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

had to reorder by pubkey

@@ -362,15 +346,21 @@ func getKeys(conf clusterConfig, numDVs int) ([]*bls_sig.SecretKey, error) {
}

// writeDepositData writes deposit data to disk for the DVs in a cluster.
func writeDepositData(config clusterConfig, pubkeys []eth2p0.BLSPubKey, msgSigs []eth2p0.BLSSignature, withdrawalAddr, network string) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

withdrawal address and network already provided in config

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 🚀

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label May 19, 2022
@obol-bulldozer obol-bulldozer bot merged commit 111fd0b into main May 19, 2022
@obol-bulldozer obol-bulldozer bot deleted the corver/depositclean branch May 19, 2022 11:01
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.

4 participants