-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
feat: improve batch validator exit UX #6327
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6327 +/- ##
============================================
- Coverage 76.61% 76.59% -0.02%
============================================
Files 248 248
Lines 25898 25907 +9
Branches 1448 1448
============================================
+ Hits 19842 19844 +2
- Misses 6026 6033 +7
Partials 30 30 |
Ran it one more time: Voluntary exit errored for 0x8069cae6625b9db897c51808d29a662038228ddf449ba0756e27f6c21c44ff2e13cae5760e6030b91e1431027559cdf5 (2183) 1/100: Internal Server Error: VOLUNTARY_EXIT_ERROR_INVALID
Voluntary exit already submitted for 99/100
- 0x80c1c1e2be166e969d86bfd99cfc6f6f44958d7c7d52d500d9a7b39a31792667f009c53c02403152f8b8d61bfe6c0f70 (2180)
- 0x8289754e5fbff939d619f329b0fc5cbd8d259bd98cc9c7e58d619fb4f54fdc5b48b3c1abb2a514e442fe575c68af458f (2132)
.... Interesting to see that one of the validators (that have already exited) reports to be: |
Performance Report✔️ no performance regression detected Full benchmark results
|
break; | ||
const alreadySubmitted = []; | ||
for (const [i, validatorToExit] of validatorsToExit.entries()) { | ||
const {err} = await wrapError(processVoluntaryExit({config, client}, exitEpoch, validatorToExit)); |
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.
If we wanted to support better logging, esp in the case an exit is already processed by the chain, we could modify isValidVoluntaryExit
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 {
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.
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.
we can do it if requested by anyone, for now this suffices as the main aim was to process all the exits and not bail early even if one errored
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.
Ok, lets make a low priority issue for it based on @barnabasbusa 's comment of:
Interesting to see that one of the validators (that have already exited) reports to be: 1/100: Internal Server Error: VOLUNTARY_EXIT_ERROR_INVALID
I read that "interesting to see" as "its weird/confusing/bad ux to see"
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.
It's not great UX to show internal server error imho, but I'm happy the bulk exists just work! Happy to get it merged as is.
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.
It's not great UX to show internal server error imho
The beacon node returning more user friendly errors could solve this as well, as per spec we should return a 400 (and not 500) error if voluntary exit is invalid.
break; | ||
const alreadySubmitted = []; | ||
for (const [i, validatorToExit] of validatorsToExit.entries()) { | ||
const {err} = await wrapError(processVoluntaryExit({config, client}, exitEpoch, validatorToExit)); |
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.
It's not great UX to show internal server error imho
The beacon node returning more user friendly errors could solve this as well, as per spec we should return a 400 (and not 500) error if voluntary exit is invalid.
@@ -2,3 +2,12 @@ | |||
* Expected error that shouldn't print a stack trace | |||
*/ | |||
export class YargsError extends Error {} | |||
|
|||
export type Result<T> = {err: null; result: T} | {err: Error}; | |||
export async function wrapError<T>(promise: Promise<T>): Promise<Result<T>> { |
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.
This function already exists as part of beacon node utils
export async function wrapError<T>(promise: Promise<T>): Promise<Result<T>> { |
Would make sense to move this to @lodestar/utils to make it more reusable across packages
🎉 This PR is included in v1.15.0 🎉 |
if there is an issue with one validator exit submission (most of the times already exited) other exits are not processed causing user frustration.
this PR processes all exits and console logs the status, and neatly handles the already exit scenarios of some of the validatoes which is what is what user faces most of the time
cc @barnabasbusa