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: check disk writes #676

Merged
merged 4 commits into from
Jun 8, 2022
Merged

dkg: check disk writes #676

merged 4 commits into from
Jun 8, 2022

Conversation

dB2510
Copy link
Contributor

@dB2510 dB2510 commented Jun 7, 2022

Check disk writes by creating random sample files and then removing sample ones if successful.

category: bug
ticket: #584

@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #676 (57c7ac1) into main (7482656) will increase coverage by 0.16%.
The diff coverage is 34.61%.

❗ Current head 57c7ac1 differs from pull request most recent head 11987d4. Consider uploading reports for the commit 11987d4 to get more accurate results

@@            Coverage Diff             @@
##             main     #676      +/-   ##
==========================================
+ Coverage   54.76%   54.92%   +0.16%     
==========================================
  Files         101      101              
  Lines        9682     9755      +73     
==========================================
+ Hits         5302     5358      +56     
- Misses       3624     3626       +2     
- Partials      756      771      +15     
Impacted Files Coverage Δ
dkg/dkg.go 53.27% <0.00%> (-0.37%) ⬇️
eth2util/keystore/keystore.go 49.55% <0.00%> (ø)
dkg/disk.go 40.74% <37.50%> (-3.53%) ⬇️
core/qbft/qbft.go 80.38% <0.00%> (-1.51%) ⬇️
dkg/exchanger.go 80.95% <0.00%> (ø)
core/consensus/component.go 61.84% <0.00%> (+0.25%) ⬆️
app/app.go 58.00% <0.00%> (+0.31%) ⬆️
core/consensus/transport.go 61.05% <0.00%> (+2.49%) ⬆️
core/parsigex/parsigex.go 75.43% <0.00%> (+29.14%) ⬆️
p2p/sender.go 57.40% <0.00%> (+57.40%) ⬆️

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 7482656...11987d4. Read the comment docs.

dkg/disk.go Outdated
if err != nil {
return errors.Wrap(err, "write deposit data")
}

return nil
}

// fileExists returns error if keystores, cluster-lock and deposit-data already exists in given dataDir.
func fileExists(dataDir string, vals int) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest checking to see if you could write by actually writing a sample file since writing files can fail for multiple reasons, not just existing files...

Copy link
Contributor

Choose a reason for hiding this comment

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

as per ticket:

The command should check for clashes (and all other disk write issues) at the start and fail with a proper message.

}

if err := os.Remove(path.Join(dataDir, fmt.Sprintf("keystore-%d.txt", i))); err != nil {
return errors.Wrap(err, fmt.Sprintf("remove sample keystore-%d.txt", i))
Copy link
Contributor

Choose a reason for hiding this comment

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

avoid sprintf in errors, rather use z.Str("file", filename)

dkg/disk.go Outdated
sigs[pk] = sig
}

if err := writeDepositData(sigs, "0x0000000000000000000000000000000000000000", "prater", dataDir); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

no const for this withdrawal addr avialble?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can be replaced with testutil.RandomETHAddress()

}

if err := writeDepositData(sigs, "0x0000000000000000000000000000000000000000", "prater", dataDir); err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these error message human friendly? Will people understand what the problem is?

func checkWrites(dataDir string, def cluster.Definition) error {
var shares []share
sigs := make(map[core.PubKey]*bls_sig.Signature)
for i := 0; i < def.NumValidators; i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

another option which is simpler is:

files := getSampleFiles(def.NumValidators)
for f in files {
  err := os.WriteFile("sample", f, 0x444)
  if err ! nil { "cannot write file", z.Str("file",f) }
  
  err := os.Remove(f)
  if err ! nil { "cannot delete file", z.Str("file",f) }
} 

@dB2510 dB2510 changed the title dkg: add file exists check and update permissions dkg: check disk writes Jun 8, 2022
@dB2510 dB2510 added the merge when ready Indicates bulldozer bot may merge when all checks pass label Jun 8, 2022
@obol-bulldozer obol-bulldozer bot merged commit 28d2342 into main Jun 8, 2022
@obol-bulldozer obol-bulldozer bot deleted the dhruv/clusterperms branch June 8, 2022 09:22
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.

None yet

2 participants