Reduce size of futures in HTTP API to prevent stack overflows (#5104)

* Box::pin a few big futures

* Arc the blocks early in publication

* Fix more tests
This commit is contained in:
Michael Sproul
2024-01-23 15:32:07 +11:00
committed by GitHub
parent 02d1f36090
commit a403138ed0
17 changed files with 116 additions and 123 deletions

View File

@@ -323,8 +323,9 @@ impl ForkChoiceTest {
)
.unwrap();
let slot = self.harness.get_current_slot();
let (mut block_tuple, mut state) = self.harness.make_block(state, slot).await;
func(&mut block_tuple.0, &mut state);
let ((block_arc, _block_blobs), mut state) = self.harness.make_block(state, slot).await;
let mut block = (*block_arc).clone();
func(&mut block, &mut state);
let current_slot = self.harness.get_current_slot();
self.harness
.chain
@@ -332,8 +333,8 @@ impl ForkChoiceTest {
.fork_choice_write_lock()
.on_block(
current_slot,
block_tuple.0.message(),
block_tuple.0.canonical_root(),
block.message(),
block.canonical_root(),
Duration::from_secs(0),
&state,
PayloadVerificationStatus::Verified,
@@ -366,8 +367,9 @@ impl ForkChoiceTest {
)
.unwrap();
let slot = self.harness.get_current_slot();
let (mut block_tuple, mut state) = self.harness.make_block(state, slot).await;
mutation_func(&mut block_tuple.0, &mut state);
let ((block_arc, _block_blobs), mut state) = self.harness.make_block(state, slot).await;
let mut block = (*block_arc).clone();
mutation_func(&mut block, &mut state);
let current_slot = self.harness.get_current_slot();
let err = self
.harness
@@ -376,8 +378,8 @@ impl ForkChoiceTest {
.fork_choice_write_lock()
.on_block(
current_slot,
block_tuple.0.message(),
block_tuple.0.canonical_root(),
block.message(),
block.canonical_root(),
Duration::from_secs(0),
&state,
PayloadVerificationStatus::Verified,

View File

@@ -90,7 +90,7 @@ async fn invalid_block_header_state_slot() {
let slot = state.slot() + Slot::new(1);
let ((signed_block, _), mut state) = harness.make_block_return_pre_state(state, slot).await;
let (mut block, signature) = signed_block.deconstruct();
let (mut block, signature) = (*signed_block).clone().deconstruct();
*block.slot_mut() = slot + Slot::new(1);
let mut ctxt = ConsensusContext::new(block.slot());
@@ -123,7 +123,7 @@ async fn invalid_parent_block_root() {
let ((signed_block, _), mut state) = harness
.make_block_return_pre_state(state, slot + Slot::new(1))
.await;
let (mut block, signature) = signed_block.deconstruct();
let (mut block, signature) = (*signed_block).clone().deconstruct();
*block.parent_root_mut() = Hash256::from([0xAA; 32]);
let mut ctxt = ConsensusContext::new(block.slot());
@@ -158,7 +158,7 @@ async fn invalid_block_signature() {
let ((signed_block, _), mut state) = harness
.make_block_return_pre_state(state, slot + Slot::new(1))
.await;
let (block, _) = signed_block.deconstruct();
let (block, _) = (*signed_block).clone().deconstruct();
let mut ctxt = ConsensusContext::new(block.slot());
let result = per_block_processing(