-
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2d6e4d6
Implement `el_offline` and use it in the VC
michaelsproul 9766347
Overhaul RequireSynced usage
michaelsproul cda5820
Clippy fixes
michaelsproul 1723c95
Update beacon_node/execution_layer/src/lib.rs
michaelsproul 3248e71
Address review comments, fix tests
michaelsproul a54f96a
Poll all BNs every slot
michaelsproul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>, | ||
} | ||
|
||
#[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 fn is_offline_or_erroring(&self) -> bool { | ||
self.engine().is_offline_blocking() || *self.inner.last_new_payload_errored.blocking_read() | ||
} | ||
|
||
/// 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,27 @@ 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. | ||
/// | ||
/// This will actually perform 2 upchecks, the 2nd one asynchronously. | ||
michaelsproul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub async fn upcheck(&self) -> Result<(), Error> { | ||
michaelsproul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.engine() | ||
.request(|engine| async { | ||
engine.upcheck().await; | ||
Ok(()) | ||
}) | ||
.await | ||
.map_err(Box::new) | ||
.map_err(Error::EngineError) | ||
} | ||
|
||
/// 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 +1239,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, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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.