fix incorrect config validation regression from #5959 (#5966)

During refactoring of #5959, some implicit `return` were overlooked,
resulting in spurious `err()` being returned without message.

```
{"lvl":"WRN","ts":"2024-02-26 10:12:20.469+00:00","msg":"Beacon nodes report different configuration values","reason":"","service":"fallback_service","node":"http://127.0.0.1:9303[Nimbus/v24.2.1-4e9bc7-stateofus]","node_index":0,"node_roles":"AGBSDT"}
```

Correcting the helpers to return explicit result in all exhaustive
cases so that this cannot happen anymore by accident.
This commit is contained in:
Etan Kissling 2024-02-26 13:32:01 +01:00 committed by Zahary Karadjov
parent 4fcfed2f1f
commit 26d0281e54
No known key found for this signature in database
GPG Key ID: C1F42EAFF38D570F
1 changed files with 14 additions and 12 deletions

View File

@ -1440,13 +1440,13 @@ proc updateRuntimeConfig*(vc: ValidatorClientRef,
localForkEpoch: Epoch, localForkEpoch: Epoch,
forkVersion: Opt[Version]): Result[void, string] = forkVersion: Opt[Version]): Result[void, string] =
if localForkVersion.isNone(): if localForkVersion.isNone():
discard # Potentially discovered new fork, save it at end of function ok() # Potentially discovered new fork, save it at end of function
else: else:
if forkVersion.isSome(): if forkVersion.isSome():
if forkVersion.get() == localForkVersion.get(): if forkVersion.get() == localForkVersion.get():
discard # Already known ok() # Already known
else: else:
return err("Beacon node has conflicting " & err("Beacon node has conflicting " &
consensusFork.forkVersionConfigKey() & " value") consensusFork.forkVersionConfigKey() & " value")
else: else:
if wallEpoch < localForkEpoch: if wallEpoch < localForkEpoch:
@ -1454,8 +1454,9 @@ proc updateRuntimeConfig*(vc: ValidatorClientRef,
node = node, node = node,
consensusFork, consensusFork,
forkEpoch = localForkEpoch forkEpoch = localForkEpoch
ok()
else: else:
return err("Beacon node must be updated and report correct " & err("Beacon node must be updated and report correct " &
$consensusFork & " config value") $consensusFork & " config value")
? ConsensusFork.Capella.validateForkVersionCompatibility( ? ConsensusFork.Capella.validateForkVersionCompatibility(
@ -1468,13 +1469,13 @@ proc updateRuntimeConfig*(vc: ValidatorClientRef,
localForkEpoch: Epoch, localForkEpoch: Epoch,
forkEpoch: Epoch): Result[void, string] = forkEpoch: Epoch): Result[void, string] =
if localForkEpoch == FAR_FUTURE_EPOCH: if localForkEpoch == FAR_FUTURE_EPOCH:
discard # Potentially discovered new fork, save it at end of function ok() # Potentially discovered new fork, save it at end of function
else: else:
if forkEpoch != FAR_FUTURE_EPOCH: if forkEpoch != FAR_FUTURE_EPOCH:
if forkEpoch == localForkEpoch: if forkEpoch == localForkEpoch:
discard # Already known ok() # Already known
else: else:
return err("Beacon node has conflicting " & err("Beacon node has conflicting " &
consensusFork.forkEpochConfigKey() & " value") consensusFork.forkEpochConfigKey() & " value")
else: else:
if wallEpoch < localForkEpoch: if wallEpoch < localForkEpoch:
@ -1482,8 +1483,9 @@ proc updateRuntimeConfig*(vc: ValidatorClientRef,
node = node, node = node,
consensusFork, consensusFork,
forkEpoch = localForkEpoch forkEpoch = localForkEpoch
ok()
else: else:
return err("Beacon node must be updated and report correct " & err("Beacon node must be updated and report correct " &
$consensusFork & " config value") $consensusFork & " config value")
? ConsensusFork.Altair.validateForkEpochCompatibility( ? ConsensusFork.Altair.validateForkEpochCompatibility(