-
Notifications
You must be signed in to change notification settings - Fork 90
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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 { |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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++ { |
There was a problem hiding this comment.
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) }
}
Check disk writes by creating random sample files and then removing sample ones if successful.
category: bug
ticket: #584