-
Notifications
You must be signed in to change notification settings - Fork 742
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
[Merged by Bors] - Implement el_offline
and use it in the VC
#4295
Changes from all commits
2d6e4d6
9766347
cda5820
1723c95
3248e71
a54f96a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,6 +222,11 @@ struct Inner<E: EthSpec> { | |
builder_profit_threshold: Uint256, | ||
log: Logger, | ||
always_prefer_builder_payload: bool, | ||
/// Track whether the last `newPayload` call errored. | ||
/// | ||
/// This is used *only* in the informational sync status endpoint, so that a VC using this | ||
/// node can prefer another node with a healthier EL. | ||
last_new_payload_errored: RwLock<bool>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had originally expected that we'd track the last fcU error rather than the last newPayload error. My reasoning was that it's the last call we'd do in the block import process so it has the most up-to-date information about EE state. However I see now that if we fail a newPayload then we won't end up calling fcU and we'd end up kinda stuck. If we're choosing just one, then I now prefer newPayload. No changes suggested, just sharing my reasoning. |
||
} | ||
|
||
#[derive(Debug, Default, Clone, Serialize, Deserialize)] | ||
|
@@ -350,6 +355,7 @@ impl<T: EthSpec> ExecutionLayer<T> { | |
builder_profit_threshold: Uint256::from(builder_profit_threshold), | ||
log, | ||
always_prefer_builder_payload, | ||
last_new_payload_errored: RwLock::new(false), | ||
}; | ||
|
||
Ok(Self { | ||
|
@@ -542,6 +548,15 @@ impl<T: EthSpec> ExecutionLayer<T> { | |
synced | ||
} | ||
|
||
/// Return `true` if the execution layer is offline or returning errors on `newPayload`. | ||
/// | ||
/// This function should never be used to prevent any operation in the beacon node, but can | ||
/// be used to give an indication on the HTTP API that the node's execution layer is struggling, | ||
/// which can in turn be used by the VC. | ||
pub async fn is_offline_or_erroring(&self) -> bool { | ||
self.engine().is_offline().await || *self.inner.last_new_payload_errored.read().await | ||
} | ||
|
||
/// Updates the proposer preparation data provided by validators | ||
pub async fn update_proposer_preparation( | ||
&self, | ||
|
@@ -1116,18 +1131,6 @@ impl<T: EthSpec> ExecutionLayer<T> { | |
} | ||
|
||
/// Maps to the `engine_newPayload` JSON-RPC call. | ||
/// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice comment cleanups 👍 |
||
/// ## Fallback Behaviour | ||
/// | ||
/// The request will be broadcast to all nodes, simultaneously. It will await a response (or | ||
/// failure) from all nodes and then return based on the first of these conditions which | ||
/// returns true: | ||
/// | ||
/// - Error::ConsensusFailure if some nodes return valid and some return invalid | ||
/// - Valid, if any nodes return valid. | ||
/// - Invalid, if any nodes return invalid. | ||
/// - Syncing, if any nodes return syncing. | ||
/// - An error, if all nodes return an error. | ||
pub async fn notify_new_payload( | ||
&self, | ||
execution_payload: &ExecutionPayload<T>, | ||
|
@@ -1156,12 +1159,18 @@ impl<T: EthSpec> ExecutionLayer<T> { | |
&["new_payload", status.status.into()], | ||
); | ||
} | ||
*self.inner.last_new_payload_errored.write().await = result.is_err(); | ||
|
||
process_payload_status(execution_payload.block_hash(), result, self.log()) | ||
.map_err(Box::new) | ||
.map_err(Error::EngineError) | ||
} | ||
|
||
/// Update engine sync status. | ||
pub async fn upcheck(&self) { | ||
self.engine().upcheck().await; | ||
} | ||
|
||
/// Register that the given `validator_index` is going to produce a block at `slot`. | ||
/// | ||
/// The block will be built atop `head_block_root` and the EL will need to prepare an | ||
|
@@ -1221,18 +1230,6 @@ impl<T: EthSpec> ExecutionLayer<T> { | |
} | ||
|
||
/// Maps to the `engine_consensusValidated` JSON-RPC call. | ||
/// | ||
/// ## Fallback Behaviour | ||
/// | ||
/// The request will be broadcast to all nodes, simultaneously. It will await a response (or | ||
/// failure) from all nodes and then return based on the first of these conditions which | ||
/// returns true: | ||
/// | ||
/// - Error::ConsensusFailure if some nodes return valid and some return invalid | ||
/// - Valid, if any nodes return valid. | ||
/// - Invalid, if any nodes return invalid. | ||
/// - Syncing, if any nodes return syncing. | ||
/// - An error, if all nodes return an error. | ||
pub async fn notify_forkchoice_updated( | ||
&self, | ||
head_block_hash: ExecutionBlockHash, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
pub mod fork_tests; | ||
pub mod interactive_tests; | ||
pub mod status_tests; | ||
pub mod tests; |
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.
Do you have thoughts on catching
EngineState::AuthFailed
as well? I think the newPayload failures would catch an auth failure in practice. I don't feel strongly either way.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.
I think it's accurate. If the auth is wrong, then the EL is effectively offline.
I imagine this would only be an issue during initial setup, or if resyncing the EE and deleting the JWT secret.