Fix failing tests after merge

This commit is contained in:
Jimmy Chen 2023-06-27 15:26:14 +10:00
parent 97c4660761
commit d062f61125
No known key found for this signature in database
GPG Key ID: 7AAEE02659DCF690
3 changed files with 28 additions and 9 deletions

View File

@ -2921,7 +2921,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
} }
} }
async fn import_available_block( pub async fn import_available_block(
self: &Arc<Self>, self: &Arc<Self>,
block: Box<AvailableExecutedBlock<T::EthSpec>>, block: Box<AvailableExecutedBlock<T::EthSpec>>,
) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> { ) -> Result<AvailabilityProcessingStatus, BlockError<T::EthSpec>> {

View File

@ -70,7 +70,7 @@ pub use attestation_verification::Error as AttestationError;
pub use beacon_fork_choice_store::{BeaconForkChoiceStore, Error as ForkChoiceStoreError}; pub use beacon_fork_choice_store::{BeaconForkChoiceStore, Error as ForkChoiceStoreError};
pub use block_verification::{ pub use block_verification::{
get_block_root, AvailabilityPendingExecutedBlock, BlockError, ExecutedBlock, get_block_root, AvailabilityPendingExecutedBlock, BlockError, ExecutedBlock,
ExecutionPayloadError, GossipVerifiedBlock, IntoExecutionPendingBlock, ExecutionPayloadError, ExecutionPendingBlock, GossipVerifiedBlock, IntoExecutionPendingBlock,
PayloadVerificationOutcome, PayloadVerificationStatus, PayloadVerificationOutcome, PayloadVerificationStatus,
}; };
pub use canonical_head::{CachedHead, CanonicalHead, CanonicalHeadRwLock}; pub use canonical_head::{CachedHead, CanonicalHead, CanonicalHeadRwLock};

View File

@ -4,6 +4,8 @@ use beacon_chain::blob_verification::BlockWrapper;
use beacon_chain::{ use beacon_chain::{
blob_verification::AsBlock, blob_verification::AsBlock,
test_utils::{AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType}, test_utils::{AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType},
AvailabilityProcessingStatus, BeaconChain, BeaconChainTypes, ExecutedBlock,
ExecutionPendingBlock,
}; };
use beacon_chain::{ use beacon_chain::{
BeaconSnapshot, BlockError, ChainSegmentResult, IntoExecutionPendingBlock, NotifyExecutionLayer, BeaconSnapshot, BlockError, ChainSegmentResult, IntoExecutionPendingBlock, NotifyExecutionLayer,
@ -1409,7 +1411,8 @@ async fn import_duplicate_block_unrealized_justification() {
// Produce a block to justify epoch 2. // Produce a block to justify epoch 2.
let state = harness.get_current_state(); let state = harness.get_current_state();
let slot = harness.get_current_slot(); let slot = harness.get_current_slot();
let (block, _) = harness.make_block(state.clone(), slot).await; let (block_contents, _) = harness.make_block(state.clone(), slot).await;
let (block, _) = block_contents;
let block = Arc::new(block); let block = Arc::new(block);
let block_root = block.canonical_root(); let block_root = block.canonical_root();
@ -1425,9 +1428,7 @@ async fn import_duplicate_block_unrealized_justification() {
.unwrap(); .unwrap();
// Import the first block, simulating a block processed via a finalized chain segment. // Import the first block, simulating a block processed via a finalized chain segment.
chain import_execution_pending_block(chain.clone(), verified_block1)
.clone()
.import_execution_pending_block(verified_block1)
.await .await
.unwrap(); .unwrap();
@ -1446,9 +1447,7 @@ async fn import_duplicate_block_unrealized_justification() {
drop(fc); drop(fc);
// Import the second verified block, simulating a block processed via RPC. // Import the second verified block, simulating a block processed via RPC.
chain import_execution_pending_block(chain.clone(), verified_block2)
.clone()
.import_execution_pending_block(verified_block2)
.await .await
.unwrap(); .unwrap();
@ -1467,3 +1466,23 @@ async fn import_duplicate_block_unrealized_justification() {
Some(unrealized_justification) Some(unrealized_justification)
); );
} }
async fn import_execution_pending_block<T: BeaconChainTypes>(
chain: Arc<BeaconChain<T>>,
execution_pending_block: ExecutionPendingBlock<T>,
) -> Result<AvailabilityProcessingStatus, String> {
match chain
.clone()
.into_executed_block(execution_pending_block)
.await
.unwrap()
{
ExecutedBlock::Available(block) => chain
.import_available_block(Box::from(block))
.await
.map_err(|e| format!("{e:?}")),
ExecutedBlock::AvailabilityPending(_) => {
Err("AvailabilityPending not expected in this test. Block not imported.".to_string())
}
}
}