lodestar
lodestar copied to clipboard
Support better voluntary exit errors
- See https://github.com/ChainSafe/lodestar/pull/6327#issuecomment-1900434692
Interesting to see that one of the validators (that have already exited) reports to be: 1/100: Internal Server Error: VOLUNTARY_EXIT_ERROR_INVALID
If we wanted to support better logging, esp in the case an exit is already processed by the chain, we could create a getVoluntaryExitValidity
to return an enum value
export enum VoluntaryExitValidity {
valid = "valid",
inactive = "inactive",
alreadyExited = "already_exited",
earlyEpoch = "early_epoch",
shortTimeActive = "short_time_active"
invalidSignature = "invalid_signature"
}
export function isValidVoluntaryExit(
state: CachedBeaconStateAllForks,
signedVoluntaryExit: phase0.SignedVoluntaryExit,
verifySignature = true
): boolean {
return getVoluntaryExitValidity(state,signedVoluntaryExit, verifySignature) === VoluntaryExitValidity.valid;
}
// this function is almost exactly what isValidVoluntaryExit was, except that each error case is handled separately,
// returning an enum value that describes the error case
export function getVoluntaryExitValidity(
state: CachedBeaconStateAllForks,
signedVoluntaryExit: phase0.SignedVoluntaryExit,
verifySignature = true
): VoluntaryExitValidity {
const {config, epochCtx} = state;
const voluntaryExit = signedVoluntaryExit.message;
const validator = state.validators.get(voluntaryExit.validatorIndex);
const currentEpoch = epochCtx.epoch;
// verify the validator is active
if(isActiveValidator(validator, currentEpoch) return VoluntaryExitValidity.inactive;
...
return VoluntaryExitValidity.valid;
}
That enum value can get passed up into an error message / code and checked against for logging.
Originally posted by @wemeetagain in https://github.com/ChainSafe/lodestar/pull/6327#discussion_r1459367323
Hi, I'd like to tackle this..
I assigned the issue to you @mabsattar, feel free to join us on discord in the #lodestar-developer channel
@mabsattar yeah best course of action is to join our discord for questions.
This feature is fairly well scoped.
Start by implementing the function described above.
Then this new function needs to be used in the validator exit flow, instead of isValidVoluntaryExit
to provide better logging. For this step, you can review the code that was added in #6327 to get a start of where you need to tweak things.