From becb81d842b099d70927ce74490f564ca506c7b1 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Thu, 31 Jan 2019 20:24:37 +1100 Subject: [PATCH] Fix memory blow-up with Arc Previously it was cloning the ChainSpec, now it shares an Arc. --- beacon_node/beacon_chain/test_harness/src/harness.rs | 8 +++++--- .../beacon_chain/test_harness/src/validator/mod.rs | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/beacon_node/beacon_chain/test_harness/src/harness.rs b/beacon_node/beacon_chain/test_harness/src/harness.rs index ee4d94148..0b493b64a 100644 --- a/beacon_node/beacon_chain/test_harness/src/harness.rs +++ b/beacon_node/beacon_chain/test_harness/src/harness.rs @@ -19,7 +19,7 @@ pub struct BeaconChainHarness { pub block_store: Arc>, pub state_store: Arc>, pub validators: Vec, - pub spec: ChainSpec, + pub spec: Arc, } impl BeaconChainHarness { @@ -74,12 +74,14 @@ impl BeaconChainHarness { .unwrap(), ); + let spec = Arc::new(spec); + debug!("Creating validator producer and attester instances..."); // Spawn the test validator instances. let validators: Vec = keypairs - .par_iter() - .map(|keypair| TestValidator::new(keypair.clone(), beacon_chain.clone(), &spec)) + .iter() + .map(|keypair| TestValidator::new(keypair.clone(), beacon_chain.clone(), spec.clone())) .collect(); debug!("Created {} TestValidators", validators.len()); diff --git a/beacon_node/beacon_chain/test_harness/src/validator/mod.rs b/beacon_node/beacon_chain/test_harness/src/validator/mod.rs index 08da1d197..018ffbc86 100644 --- a/beacon_node/beacon_chain/test_harness/src/validator/mod.rs +++ b/beacon_node/beacon_chain/test_harness/src/validator/mod.rs @@ -52,9 +52,8 @@ impl TestValidator { pub fn new( keypair: Keypair, beacon_chain: Arc>, - spec: &ChainSpec, + spec: Arc, ) -> Self { - let spec = Arc::new(spec.clone()); let slot_clock = Arc::new(TestingSlotClock::new(spec.genesis_slot)); let signer = Arc::new(TestSigner::new(keypair.clone())); let beacon_node = Arc::new(BenchingBeaconNode::new(beacon_chain.clone()));