diff --git a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs index 02d35acaa82..48ec5d1b2bb 100644 --- a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs +++ b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs @@ -39,13 +39,6 @@ impl ValidatorPubkeyCache { state: &BeaconState, persistence_path: P, ) -> Result { - if persistence_path.as_ref().exists() { - return Err(BeaconChainError::ValidatorPubkeyCacheFileError(format!( - "Persistence file already exists: {:?}", - persistence_path.as_ref() - ))); - } - let mut cache = Self { persitence_file: ValidatorPubkeyCacheFile::create(persistence_path)?, pubkeys: vec![], @@ -159,8 +152,9 @@ impl ValidatorPubkeyCacheFile { /// Creates a file for reading and writing. pub fn create>(path: P) -> Result { OpenOptions::new() - .create_new(true) + .create(true) .write(true) + .truncate(true) .open(path) .map(Self) .map_err(Error::Io)