-
Notifications
You must be signed in to change notification settings - Fork 797
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
Reduce size of futures in HTTP API to prevent stack overflows #5104
Merged
paulhauner
merged 3 commits into
sigp:unstable
from
michaelsproul:http-stack-overflow-fix
Jan 23, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -194,7 +194,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten | |||||
|
||||||
if let Some(gossip_verified_blobs) = gossip_verified_blobs { | ||||||
for blob in gossip_verified_blobs { | ||||||
if let Err(e) = chain.process_gossip_blob(blob).await { | ||||||
if let Err(e) = Box::pin(chain.process_gossip_blob(blob)).await { | ||||||
let msg = format!("Invalid blob: {e}"); | ||||||
return if let BroadcastValidation::Gossip = validation_level { | ||||||
Err(warp_utils::reject::broadcast_without_import(msg)) | ||||||
|
@@ -210,14 +210,13 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten | |||||
} | ||||||
} | ||||||
|
||||||
match chain | ||||||
.process_block( | ||||||
block_root, | ||||||
gossip_verified_block, | ||||||
NotifyExecutionLayer::Yes, | ||||||
publish_fn, | ||||||
) | ||||||
.await | ||||||
match Box::pin(chain.process_block( | ||||||
block_root, | ||||||
gossip_verified_block, | ||||||
NotifyExecutionLayer::Yes, | ||||||
publish_fn, | ||||||
)) | ||||||
.await | ||||||
{ | ||||||
Ok(AvailabilityProcessingStatus::Imported(root)) => { | ||||||
info!( | ||||||
|
@@ -291,7 +290,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten | |||||
/// Handles a request from the HTTP API for blinded blocks. This converts blinded blocks into full | ||||||
/// blocks before publishing. | ||||||
pub async fn publish_blinded_block<T: BeaconChainTypes>( | ||||||
blinded_block: SignedBlindedBeaconBlock<T::EthSpec>, | ||||||
blinded_block: Arc<SignedBlindedBeaconBlock<T::EthSpec>>, | ||||||
chain: Arc<BeaconChain<T>>, | ||||||
network_tx: &UnboundedSender<NetworkMessage<T::EthSpec>>, | ||||||
log: Logger, | ||||||
|
@@ -319,7 +318,7 @@ pub async fn publish_blinded_block<T: BeaconChainTypes>( | |||||
pub async fn reconstruct_block<T: BeaconChainTypes>( | ||||||
chain: Arc<BeaconChain<T>>, | ||||||
block_root: Hash256, | ||||||
block: SignedBlindedBeaconBlock<T::EthSpec>, | ||||||
block: Arc<SignedBlindedBeaconBlock<T::EthSpec>>, | ||||||
log: Logger, | ||||||
) -> Result<ProvenancedBlock<T, PublishBlockRequest<T::EthSpec>>, Rejection> { | ||||||
let full_payload_opt = if let Ok(payload_header) = block.message().body().execution_payload() { | ||||||
|
@@ -380,6 +379,10 @@ pub async fn reconstruct_block<T: BeaconChainTypes>( | |||||
None | ||||||
}; | ||||||
|
||||||
// Perf: cloning the block here to unblind it is a little sub-optimal. This is considered an | ||||||
// acceptable tradeoff to avoid passing blocks around on the stack (unarced), which blows up | ||||||
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.
Suggested change
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 kinda like the lowercase spelling |
||||||
// the size of futures. | ||||||
let block = (*block).clone(); | ||||||
match full_payload_opt { | ||||||
// A block without a payload is pre-merge and we consider it locally | ||||||
// built. | ||||||
|
Oops, something went wrong.
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.
is this test only code? If so do we also have stack overflows during tests?
(Question applies to all the uses in this file)
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.
yeah this is just for tests, I ended up having to make quite a few changes to make the types consistent. There's a bit of inefficient Arc-ing and de-Arc-ing, but it's just in tests so it shouldn't be too bad
Jimmy got some stack overflows in tests, but only in debug mode