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

VC: Fix issue when optimistically synced node could block sync committee service functions. #4878

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 14 additions & 8 deletions beacon_chain/validator_client/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const
ResponseNotFoundError = "Received resource missing error response"
ResponseNoSyncError = "Received nosync error response"
ResponseDecodeError = "Received response could not be decoded"
ResponseECNotInSyncError* = "Execution client not in sync"

type
ApiResponse*[T] = Result[T, string]
Expand Down Expand Up @@ -1138,7 +1139,9 @@ proc getHeadBlockRoot*(
let data = res.get()
if data.execution_optimistic.get(false):
node.updateStatus(RestBeaconNodeStatus.OptSynced)
ApiResponse[GetBlockRootResponse].ok(data)
ApiResponse[GetBlockRootResponse].err(ResponseECNotInSyncError)
else:
ApiResponse[GetBlockRootResponse].ok(data)
of 400:
debug ResponseInvalidError, response_code = response.status,
endpoint = node, reason = response.getErrorMessage()
Expand Down Expand Up @@ -1189,13 +1192,16 @@ proc getHeadBlockRoot*(
let data = res.get()
if data.execution_optimistic.get(false):
node.updateStatus(RestBeaconNodeStatus.OptSynced)
return data

debug ResponseDecodeError, response_code = response.status,
endpoint = node, reason = res.error
node.updateStatus(RestBeaconNodeStatus.Unexpected)
failures.add(ApiNodeFailure.init(node, ApiFailure.Invalid))
false
failures.add(ApiNodeFailure.init(node, ApiFailure.Invalid))
false
else:
return data
else:
debug ResponseDecodeError, response_code = response.status,
endpoint = node, reason = res.error
node.updateStatus(RestBeaconNodeStatus.Unexpected)
failures.add(ApiNodeFailure.init(node, ApiFailure.Invalid))
false
of 400:
debug ResponseInvalidError, response_code = response.status,
endpoint = node, reason = response.getErrorMessage()
Expand Down
5 changes: 2 additions & 3 deletions beacon_chain/validator_client/sync_committee_service.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2022 Status Research & Development GmbH
# Copyright (c) 2022-2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
Expand Down Expand Up @@ -360,8 +360,7 @@ proc publishSyncMessagesAndContributions(service: SyncCommitteeServiceRef,
res.data.root
else:
if res.execution_optimistic.get():
notice "Execution client not in sync; skipping validator duties " &
"for now", slot = slot
notice "Execution client not in sync", slot = slot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per changes to getHeadBlockRoot we can no longer end up in this branch of the logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

return
res.data.root
except ValidatorApiError as exc:
Expand Down