mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Fix memory blow-up with Arc<ChainSpec>
Previously it was cloning the ChainSpec, now it shares an Arc.
This commit is contained in:
@@ -19,7 +19,7 @@ pub struct BeaconChainHarness {
|
|||||||
pub block_store: Arc<BeaconBlockStore<MemoryDB>>,
|
pub block_store: Arc<BeaconBlockStore<MemoryDB>>,
|
||||||
pub state_store: Arc<BeaconStateStore<MemoryDB>>,
|
pub state_store: Arc<BeaconStateStore<MemoryDB>>,
|
||||||
pub validators: Vec<TestValidator>,
|
pub validators: Vec<TestValidator>,
|
||||||
pub spec: ChainSpec,
|
pub spec: Arc<ChainSpec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BeaconChainHarness {
|
impl BeaconChainHarness {
|
||||||
@@ -74,12 +74,14 @@ impl BeaconChainHarness {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let spec = Arc::new(spec);
|
||||||
|
|
||||||
debug!("Creating validator producer and attester instances...");
|
debug!("Creating validator producer and attester instances...");
|
||||||
|
|
||||||
// Spawn the test validator instances.
|
// Spawn the test validator instances.
|
||||||
let validators: Vec<TestValidator> = keypairs
|
let validators: Vec<TestValidator> = keypairs
|
||||||
.par_iter()
|
.iter()
|
||||||
.map(|keypair| TestValidator::new(keypair.clone(), beacon_chain.clone(), &spec))
|
.map(|keypair| TestValidator::new(keypair.clone(), beacon_chain.clone(), spec.clone()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
debug!("Created {} TestValidators", validators.len());
|
debug!("Created {} TestValidators", validators.len());
|
||||||
|
|||||||
@@ -52,9 +52,8 @@ impl TestValidator {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
keypair: Keypair,
|
keypair: Keypair,
|
||||||
beacon_chain: Arc<BeaconChain<MemoryDB, TestingSlotClock>>,
|
beacon_chain: Arc<BeaconChain<MemoryDB, TestingSlotClock>>,
|
||||||
spec: &ChainSpec,
|
spec: Arc<ChainSpec>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let spec = Arc::new(spec.clone());
|
|
||||||
let slot_clock = Arc::new(TestingSlotClock::new(spec.genesis_slot));
|
let slot_clock = Arc::new(TestingSlotClock::new(spec.genesis_slot));
|
||||||
let signer = Arc::new(TestSigner::new(keypair.clone()));
|
let signer = Arc::new(TestSigner::new(keypair.clone()));
|
||||||
let beacon_node = Arc::new(BenchingBeaconNode::new(beacon_chain.clone()));
|
let beacon_node = Arc::new(BenchingBeaconNode::new(beacon_chain.clone()));
|
||||||
|
|||||||
Reference in New Issue
Block a user