Skip to content

Commit

Permalink
Fix slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Feb 21, 2024
1 parent f34f6b6 commit 0e90df8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/validators/api/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,19 @@ async def submit_validators(request: Request) -> Response:
keystore=None, deposit_data=deposit_data
)

error = await _validate_registration_requests(registration_requests, validators)
if error is not None:
return JSONResponse({'error': error}, status_code=HTTP_400_BAD_REQUEST)

# There may be lag between GET and POST requests.
# During this time new assets may be staked into the vault.
# In this case validators list will be longer than requests list.
# Filter validators by requested public keys.
validators = validators[: len(registration_requests)]
#
# If someone unstakes funds then validators list may become shorter
# than requests list
#
common_length = min(len(validators), len(registration_requests))
registration_requests = registration_requests[:common_length]

error = await _validate_registration_requests(registration_requests, validators)
if error is not None:
return JSONResponse({'error': error}, status_code=HTTP_400_BAD_REQUEST)

for validator, registration_request in zip(validators, registration_requests):
validator.exit_signature = registration_request.exit_signature
Expand Down

0 comments on commit 0e90df8

Please sign in to comment.