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

*: flag refactors #3198

Merged
merged 6 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
flags.IntVar(&config.NumDVs, "num-validators", 0, "The number of distributed validators needed in the cluster.")
flags.BoolVar(&config.SplitKeys, "split-existing-keys", false, "Split an existing validator's private key into a set of distributed validator private key shares. Does not re-create deposit data for this key.")
flags.StringVar(&config.SplitKeysDir, "split-keys-dir", "", "Directory containing keys to split. Expects keys in keystore-*.json and passwords in keystore-*.txt. Requires --split-existing-keys.")
flags.StringVar(&config.PublishAddr, "publish-address", "https://api.obol.tech", "The URL to publish the lock file to.")
flags.StringVar(&config.PublishAddr, "publish-address", "https://api.obol.tech/v1", "The URL to publish the lock file to.")

Check warning on line 118 in cmd/createcluster.go

View check run for this annotation

Codecov / codecov/patch

cmd/createcluster.go#L118

Added line #L118 was not covered by tests
flags.BoolVar(&config.Publish, "publish", false, "Publish lock file to obol-api.")
flags.StringVar(&config.testnetConfig.Name, "testnet-name", "", "Name of the custom test network.")
flags.StringVar(&config.testnetConfig.GenesisForkVersionHex, "testnet-fork-version", "", "Genesis fork version of the custom test network (in hex).")
Expand Down
2 changes: 1 addition & 1 deletion cmd/dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
}

func bindPublishFlags(flags *pflag.FlagSet, config *dkg.Config) {
flags.StringVar(&config.PublishAddr, "publish-address", "https://api.obol.tech", "The URL to publish the cluster to.")
flags.StringVar(&config.PublishAddr, "publish-address", "https://api.obol.tech/v1", "The URL to publish the cluster to.")

Check warning on line 68 in cmd/dkg.go

View check run for this annotation

Codecov / codecov/patch

cmd/dkg.go#L68

Added line #L68 was not covered by tests
flags.DurationVar(&config.PublishTimeout, "publish-timeout", 30*time.Second, "Timeout for publishing a cluster, consider increasing if the cluster contains more than 200 validators.")
flags.BoolVar(&config.Publish, "publish", false, "Publish the created cluster to a remote API.")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@

switch flag {
case publishAddress:
cmd.Flags().StringVar(&config.PublishAddress, publishAddress.String(), "https://api.obol.tech", maybeRequired("The URL of the remote API."))
cmd.Flags().StringVar(&config.PublishAddress, publishAddress.String(), "https://api.obol.tech/v1", maybeRequired("The URL of the remote API."))

Check warning on line 118 in cmd/exit.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit.go#L118

Added line #L118 was not covered by tests
case beaconNodeEndpoints:
cmd.Flags().StringSliceVar(&config.BeaconNodeEndpoints, beaconNodeEndpoints.String(), nil, maybeRequired("Comma separated list of one or more beacon node endpoint URLs."))
case privateKeyPath:
Expand All @@ -137,7 +137,7 @@
case publishTimeout:
cmd.Flags().DurationVar(&config.PublishTimeout, publishTimeout.String(), 30*time.Second, "Timeout for publishing a signed exit to the publish-address API.")
case validatorIndex:
cmd.Flags().Uint64Var(&config.ValidatorIndex, validatorIndex.String(), 0, "Validator index of the validator to exit, the associated public key must be present in the cluster lock manifest. If --validator-pubkey is also provided, validator liveliness won't be checked on the beacon chain.")
cmd.Flags().Uint64Var(&config.ValidatorIndex, validatorIndex.String(), 0, "Validator index of the validator to exit, the associated public key must be present in the cluster lock manifest. If --validator-public-key is also provided, validator liveliness won't be checked on the beacon chain.")

Check warning on line 140 in cmd/exit.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit.go#L140

Added line #L140 was not covered by tests
KaloyanTanev marked this conversation as resolved.
Show resolved Hide resolved
}

if f.required {
Expand Down
2 changes: 1 addition & 1 deletion cmd/exit_broadcast_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func Test_runBcastFullExitCmd_Config(t *testing.T) {

oapiURL := badStr
if !test.badOAPIURL {
oapiURL = "https://api.obol.tech"
oapiURL = "https://api.obol.tech/v1"
}

valAddr := badStr
Expand Down
2 changes: 1 addition & 1 deletion cmd/exit_sign_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func Test_runSubmitPartialExit_Config(t *testing.T) {

oapiURL := badStr
if !test.badOAPIURL {
oapiURL = "https://api.obol.tech"
oapiURL = "https://api.obol.tech/v1"
}

valAddr := badStr
Expand Down
4 changes: 2 additions & 2 deletions cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const (
// measurement tests
testVerdictGood testVerdict = "Good"
testVerdictAvg testVerdict = "Avg"
KaloyanTanev marked this conversation as resolved.
Show resolved Hide resolved
testVerdictBad testVerdict = "Bad"
testVerdictPoor testVerdict = "Poor"

// failed tests
testVerdictFail testVerdict = "Fail"
Expand Down Expand Up @@ -274,7 +274,7 @@ func calculateScore(results []testResult) categoryScore {
avg := 0
for _, t := range results {
switch t.Verdict {
case testVerdictBad:
case testVerdictPoor:
return categoryScoreC
case testVerdictGood:
avg++
Expand Down
24 changes: 12 additions & 12 deletions cmd/testbeacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
type testCaseBeacon func(context.Context, *testBeaconConfig, string) testResult

const (
thresholdBeaconMeasureAvg = 40 * time.Millisecond
thresholdBeaconMeasureBad = 100 * time.Millisecond
thresholdBeaconLoadAvg = 40 * time.Millisecond
thresholdBeaconLoadBad = 100 * time.Millisecond
thresholdBeaconPeersAvg = 50
thresholdBeaconPeersBad = 20
thresholdBeaconMeasureAvg = 40 * time.Millisecond
thresholdBeaconMeasurePoor = 100 * time.Millisecond
thresholdBeaconLoadAvg = 40 * time.Millisecond
thresholdBeaconLoadPoor = 100 * time.Millisecond
thresholdBeaconPeersAvg = 50
thresholdBeaconPeersPoor = 20
)

func newTestBeaconCmd(runFunc func(context.Context, io.Writer, testBeaconConfig) error) *cobra.Command {
Expand Down Expand Up @@ -278,8 +278,8 @@
return failedTestResult(testRes, err)
}

if rtt > thresholdBeaconMeasureBad {
testRes.Verdict = testVerdictBad
if rtt > thresholdBeaconMeasurePoor {
testRes.Verdict = testVerdictPoor

Check warning on line 282 in cmd/testbeacon.go

View check run for this annotation

Codecov / codecov/patch

cmd/testbeacon.go#L282

Added line #L282 was not covered by tests
} else if rtt > thresholdBeaconMeasureAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -345,8 +345,8 @@
highestRTT = rtt
}
}
if highestRTT > thresholdBeaconLoadBad {
testRes.Verdict = testVerdictBad
if highestRTT > thresholdBeaconLoadPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 349 in cmd/testbeacon.go

View check run for this annotation

Codecov / codecov/patch

cmd/testbeacon.go#L348-L349

Added lines #L348 - L349 were not covered by tests
} else if highestRTT > thresholdBeaconLoadAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -441,8 +441,8 @@

testRes.Measurement = strconv.Itoa(respUnmarshaled.Meta.Count)

if respUnmarshaled.Meta.Count < thresholdBeaconPeersBad {
testRes.Verdict = testVerdictBad
if respUnmarshaled.Meta.Count < thresholdBeaconPeersPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 445 in cmd/testbeacon.go

View check run for this annotation

Codecov / codecov/patch

cmd/testbeacon.go#L445

Added line #L445 was not covered by tests
} else if respUnmarshaled.Meta.Count < thresholdBeaconPeersAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down
8 changes: 4 additions & 4 deletions cmd/testmev.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
type testCaseMEV func(context.Context, *testMEVConfig, string) testResult

const (
thresholdMEVMeasureAvg = 40 * time.Millisecond
thresholdMEVMeasureBad = 100 * time.Millisecond
thresholdMEVMeasureAvg = 40 * time.Millisecond
thresholdMEVMeasurePoor = 100 * time.Millisecond
)

func newTestMEVCmd(runFunc func(context.Context, io.Writer, testMEVConfig) error) *cobra.Command {
Expand Down Expand Up @@ -250,8 +250,8 @@
return failedTestResult(testRes, errors.New("status code %v", z.Int("status_code", resp.StatusCode)))
}

if firstByte > thresholdMEVMeasureBad {
testRes.Verdict = testVerdictBad
if firstByte > thresholdMEVMeasurePoor {
testRes.Verdict = testVerdictPoor

Check warning on line 254 in cmd/testmev.go

View check run for this annotation

Codecov / codecov/patch

cmd/testmev.go#L254

Added line #L254 was not covered by tests
} else if firstByte > thresholdMEVMeasureAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down
24 changes: 12 additions & 12 deletions cmd/testpeers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
)

const (
thresholdPeersMeasureAvg = 50 * time.Millisecond
thresholdPeersMeasureBad = 240 * time.Millisecond
thresholdPeersLoadAvg = 50 * time.Millisecond
thresholdPeersLoadBad = 240 * time.Millisecond
thresholdRelayMeasureAvg = 50 * time.Millisecond
thresholdRelayMeasureBad = 240 * time.Millisecond
thresholdPeersMeasureAvg = 50 * time.Millisecond
thresholdPeersMeasurePoor = 240 * time.Millisecond
thresholdPeersLoadAvg = 50 * time.Millisecond
thresholdPeersLoadPoor = 240 * time.Millisecond
thresholdRelayMeasureAvg = 50 * time.Millisecond
thresholdRelayMeasurePoor = 240 * time.Millisecond
)

func newTestPeersCmd(runFunc func(context.Context, io.Writer, testPeersConfig) error) *cobra.Command {
Expand Down Expand Up @@ -605,8 +605,8 @@
return failedTestResult(testRes, result.Error)
}

if result.RTT > thresholdPeersMeasureBad {
testRes.Verdict = testVerdictBad
if result.RTT > thresholdPeersMeasurePoor {
testRes.Verdict = testVerdictPoor

Check warning on line 609 in cmd/testpeers.go

View check run for this annotation

Codecov / codecov/patch

cmd/testpeers.go#L609

Added line #L609 was not covered by tests
} else if result.RTT > thresholdPeersMeasureAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -652,8 +652,8 @@
highestRTT = val.RTT
}
}
if highestRTT > thresholdPeersLoadBad {
testRes.Verdict = testVerdictBad
if highestRTT > thresholdPeersLoadPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 656 in cmd/testpeers.go

View check run for this annotation

Codecov / codecov/patch

cmd/testpeers.go#L656

Added line #L656 was not covered by tests
} else if highestRTT > thresholdPeersLoadAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -788,8 +788,8 @@
return failedTestResult(testRes, errors.New("status code %v", z.Int("status_code", resp.StatusCode)))
}

if firstByte > thresholdRelayMeasureBad {
testRes.Verdict = testVerdictBad
if firstByte > thresholdRelayMeasurePoor {
testRes.Verdict = testVerdictPoor

Check warning on line 792 in cmd/testpeers.go

View check run for this annotation

Codecov / codecov/patch

cmd/testpeers.go#L792

Added line #L792 was not covered by tests
} else if firstByte > thresholdRelayMeasureAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down
4 changes: 2 additions & 2 deletions cmd/testpeers_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestPeersTest(t *testing.T) {
OutputToml: "",
Quiet: true,
TestCases: nil,
Timeout: 200 * time.Millisecond,
Timeout: time.Second,
},
ENRs: []string{
"enr:-HW4QBHlcyD3fYWUMADiOv4OxODaL5wJG0a7P7d_ltu4VZe1MibZ1N-twFaoaq0BoCtXcY71etxLJGeEZT5p3XCO6GOAgmlkgnY0iXNlY3AyNTZrMaEDI2HRUlVBag__njkOWEEQRLlC9ylIVCrIXOuNBSlrx6o",
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestPeersTest(t *testing.T) {
OutputToml: "",
Quiet: false,
TestCases: []string{"ping"},
Timeout: 200 * time.Millisecond,
Timeout: time.Second,
},
ENRs: []string{
"enr:-HW4QBHlcyD3fYWUMADiOv4OxODaL5wJG0a7P7d_ltu4VZe1MibZ1N-twFaoaq0BoCtXcY71etxLJGeEZT5p3XCO6GOAgmlkgnY0iXNlY3AyNTZrMaEDI2HRUlVBag__njkOWEEQRLlC9ylIVCrIXOuNBSlrx6o",
Expand Down
50 changes: 25 additions & 25 deletions cmd/testperformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
}

const (
diskWriteLoops = 5
diskWriteMBsAvg = 1000
diskWriteMBsBad = 500
availableMemoryMBsAvg = 4000
availableMemoryMBsBad = 2000
totalMemoryMBsAvg = 8000
totalMemoryMBsBad = 4000
internetLatencyAvg = 20 * time.Millisecond
internetLatencyBad = 50 * time.Millisecond
internetDownloadSpeedMbpsAvg = 50
internetDownloadSpeedMbpsBad = 15
internetUploadSpeedMbpsAvg = 50
internetUploadSpeedMbpsBad = 15
diskWriteLoops = 5
diskWriteMBsAvg = 1000
diskWriteMBsPoor = 500
availableMemoryMBsAvg = 4000
availableMemoryMBsPoor = 2000
totalMemoryMBsAvg = 8000
totalMemoryMBsPoor = 4000
internetLatencyAvg = 20 * time.Millisecond
internetLatencyPoor = 50 * time.Millisecond
internetDownloadSpeedMbpsAvg = 50
internetDownloadSpeedMbpsPoor = 15
internetUploadSpeedMbpsAvg = 50
internetUploadSpeedMbpsPoor = 15
)

func newTestPerformanceCmd(runFunc func(context.Context, io.Writer, testPerformanceConfig) error) *cobra.Command {
Expand Down Expand Up @@ -227,8 +227,8 @@

diskWriteFinal := diskWriteTotal / diskWriteLoops

if diskWriteFinal < diskWriteMBsBad {
testRes.Verdict = testVerdictBad
if diskWriteFinal < diskWriteMBsPoor {
testRes.Verdict = testVerdictPoor
} else if diskWriteFinal < diskWriteMBsAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -388,8 +388,8 @@

availableMemoryMB := availableMemory / 1024 / 1024

if availableMemoryMB < availableMemoryMBsBad {
testRes.Verdict = testVerdictBad
if availableMemoryMB < availableMemoryMBsPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 392 in cmd/testperformance.go

View check run for this annotation

Codecov / codecov/patch

cmd/testperformance.go#L392

Added line #L392 was not covered by tests
} else if availableMemoryMB < availableMemoryMBsAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -466,8 +466,8 @@

totalMemoryMB := totalMemory / 1024 / 1024

if totalMemoryMB < totalMemoryMBsBad {
testRes.Verdict = testVerdictBad
if totalMemoryMB < totalMemoryMBsPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 470 in cmd/testperformance.go

View check run for this annotation

Codecov / codecov/patch

cmd/testperformance.go#L470

Added line #L470 was not covered by tests
} else if totalMemoryMB < totalMemoryMBsAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -537,8 +537,8 @@
}
latency := server.Latency

if latency > internetLatencyBad {
testRes.Verdict = testVerdictBad
if latency > internetLatencyPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 541 in cmd/testperformance.go

View check run for this annotation

Codecov / codecov/patch

cmd/testperformance.go#L541

Added line #L541 was not covered by tests
} else if latency > internetLatencyAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -569,8 +569,8 @@
}
downloadSpeed := server.DLSpeed.Mbps()

if downloadSpeed < internetDownloadSpeedMbpsBad {
testRes.Verdict = testVerdictBad
if downloadSpeed < internetDownloadSpeedMbpsPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 573 in cmd/testperformance.go

View check run for this annotation

Codecov / codecov/patch

cmd/testperformance.go#L572-L573

Added lines #L572 - L573 were not covered by tests
} else if downloadSpeed < internetDownloadSpeedMbpsAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down Expand Up @@ -601,8 +601,8 @@
}
uploadSpeed := server.ULSpeed.Mbps()

if uploadSpeed < internetUploadSpeedMbpsBad {
testRes.Verdict = testVerdictBad
if uploadSpeed < internetUploadSpeedMbpsPoor {
testRes.Verdict = testVerdictPoor

Check warning on line 605 in cmd/testperformance.go

View check run for this annotation

Codecov / codecov/patch

cmd/testperformance.go#L604-L605

Added lines #L604 - L605 were not covered by tests
} else if uploadSpeed < internetUploadSpeedMbpsAvg {
testRes.Verdict = testVerdictAvg
} else {
Expand Down
26 changes: 13 additions & 13 deletions cmd/testperformance_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func TestPerformanceTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
"local": {
{Name: "diskWrite", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "availableMemory", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "totalMemory", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "internetLatency", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "diskWrite", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "availableMemory", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "totalMemory", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "internetLatency", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
},
},
Score: categoryScoreC,
Expand Down Expand Up @@ -88,10 +88,10 @@ func TestPerformanceTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
"local": {
{Name: "diskWrite", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "availableMemory", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "totalMemory", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "internetLatency", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "diskWrite", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "availableMemory", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "totalMemory", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "internetLatency", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
},
},
Score: categoryScoreC,
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestPerformanceTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
"local": {
{Name: "diskWrite", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "diskWrite", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
},
},
Score: categoryScoreC,
Expand All @@ -152,10 +152,10 @@ func TestPerformanceTest(t *testing.T) {
expected: testCategoryResult{
Targets: map[string][]testResult{
"local": {
{Name: "diskWrite", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "availableMemory", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "totalMemory", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "internetLatency", Verdict: testVerdictBad, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "diskWrite", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "availableMemory", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "totalMemory", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "internetLatency", Verdict: testVerdictPoor, Measurement: "", Suggestion: "", Error: testResultError{}},
},
},
Score: categoryScoreC,
Expand Down
Loading
Loading