mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 04:44:28 +00:00
Trying more stuff
This commit is contained in:
@@ -3,9 +3,10 @@
|
|||||||
use beacon_chain::{
|
use beacon_chain::{
|
||||||
builder::BeaconChainBuilder,
|
builder::BeaconChainBuilder,
|
||||||
test_utils::{get_kzg, mock_execution_layer_from_parts, BeaconChainHarness, DiskHarnessType},
|
test_utils::{get_kzg, mock_execution_layer_from_parts, BeaconChainHarness, DiskHarnessType},
|
||||||
ChainConfig, MigratorConfig, StateSkipConfig,
|
ChainConfig, MigratorConfig, NotifyExecutionLayer, StateSkipConfig,
|
||||||
};
|
};
|
||||||
use logging::test_logger;
|
use logging::test_logger;
|
||||||
|
use slog::debug;
|
||||||
use slot_clock::{SlotClock, TestingSlotClock};
|
use slot_clock::{SlotClock, TestingSlotClock};
|
||||||
use state_processing::{
|
use state_processing::{
|
||||||
per_block_processing, BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot,
|
per_block_processing, BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot,
|
||||||
@@ -140,7 +141,7 @@ async fn signature_verify_chain_segment_pubkey_cache() {
|
|||||||
pre_finalized_deposit_state.validators().len(),
|
pre_finalized_deposit_state.validators().len(),
|
||||||
initial_validator_count
|
initial_validator_count
|
||||||
);
|
);
|
||||||
let new_epoch_start_slot = pre_finalized_deposit_state.slot() + E::slots_per_epoch() + 1;
|
let new_epoch_start_slot = pre_finalized_deposit_state.slot() + 3 * E::slots_per_epoch() + 1;
|
||||||
|
|
||||||
// New validator should not be in the pubkey cache yet.
|
// New validator should not be in the pubkey cache yet.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -152,12 +153,10 @@ async fn signature_verify_chain_segment_pubkey_cache() {
|
|||||||
);
|
);
|
||||||
let new_validator_index = initial_validator_count;
|
let new_validator_index = initial_validator_count;
|
||||||
|
|
||||||
// Produce blocks in the next epoch. Statistically one of these should be signed by our new
|
// Produce blocks in the next 3 epochs. Statistically one of these should be signed by our new
|
||||||
// validator (99% probability).
|
// validator (99% probability).
|
||||||
harness.extend_to_slot(new_epoch_start_slot).await;
|
harness.extend_to_slot(new_epoch_start_slot).await;
|
||||||
|
|
||||||
let chain_dump = harness.chain.chain_dump();
|
|
||||||
|
|
||||||
// New validator should be in the pubkey cache now.
|
// New validator should be in the pubkey cache now.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
harness
|
harness
|
||||||
@@ -212,7 +211,9 @@ async fn signature_verify_chain_segment_pubkey_cache() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let (shutdown_tx, _shutdown_rx) = futures::channel::mpsc::channel(1);
|
let (shutdown_tx, _shutdown_rx) = futures::channel::mpsc::channel(1);
|
||||||
|
|
||||||
let beacon_chain = BeaconChainBuilder::<DiskHarnessType<E>>::new(MainnetEthSpec, kzg)
|
let log = harness.runtime.log.clone();
|
||||||
|
let beacon_chain = Arc::new(
|
||||||
|
BeaconChainBuilder::<DiskHarnessType<E>>::new(MainnetEthSpec, kzg)
|
||||||
.store(store.clone())
|
.store(store.clone())
|
||||||
.custom_spec(spec.clone())
|
.custom_spec(spec.clone())
|
||||||
.task_executor(harness.chain.task_executor.clone())
|
.task_executor(harness.chain.task_executor.clone())
|
||||||
@@ -232,5 +233,58 @@ async fn signature_verify_chain_segment_pubkey_cache() {
|
|||||||
.chain_config(ChainConfig::default())
|
.chain_config(ChainConfig::default())
|
||||||
.execution_layer(Some(mock.el))
|
.execution_layer(Some(mock.el))
|
||||||
.build()
|
.build()
|
||||||
.expect("should build");
|
.expect("should build"),
|
||||||
|
);
|
||||||
|
|
||||||
|
let chain_dump = harness.chain.chain_dump().unwrap();
|
||||||
|
let new_blocks = chain_dump
|
||||||
|
.iter()
|
||||||
|
.filter(|snapshot| snapshot.beacon_block.slot() > checkpoint_slot);
|
||||||
|
|
||||||
|
let mut chain_segment = vec![];
|
||||||
|
let mut new_proposer_present = false;
|
||||||
|
for snapshot in new_blocks {
|
||||||
|
let block_root = snapshot.beacon_block_root;
|
||||||
|
let full_block = harness.chain.get_block(&block_root).await.unwrap().unwrap();
|
||||||
|
|
||||||
|
new_proposer_present |= full_block.message().proposer_index() == new_validator_index as u64;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Proposal from validator {} at slot {}",
|
||||||
|
full_block.message().proposer_index(),
|
||||||
|
full_block.slot()
|
||||||
|
);
|
||||||
|
|
||||||
|
chain_segment
|
||||||
|
.push(harness.build_rpc_block_from_store_blobs(Some(block_root), Arc::new(full_block)));
|
||||||
|
}
|
||||||
|
assert_ne!(chain_segment.len(), 0);
|
||||||
|
|
||||||
|
// This should succeed despite the new validator index being unknown to the checkpoint synced
|
||||||
|
// chain.
|
||||||
|
/*
|
||||||
|
assert!(
|
||||||
|
new_proposer_present,
|
||||||
|
"new proposer should be part of chain segment"
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
assert_eq!(
|
||||||
|
beacon_chain
|
||||||
|
.validator_index(&new_validator_pk_bytes)
|
||||||
|
.unwrap(),
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
beacon_chain
|
||||||
|
.process_chain_segment(chain_segment, NotifyExecutionLayer::Yes)
|
||||||
|
.await
|
||||||
|
.into_block_error()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// Processing the chain segment should add the new validator to the cache.
|
||||||
|
assert_eq!(
|
||||||
|
beacon_chain
|
||||||
|
.validator_index(&new_validator_pk_bytes)
|
||||||
|
.unwrap(),
|
||||||
|
Some(new_validator_index),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user