Skip to content

Commit

Permalink
removed unnecessary, incorrect check for previous genesis write (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbar authored Apr 15, 2024
1 parent 2cc3814 commit fa16ca6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
11 changes: 0 additions & 11 deletions src/processor/snapshot/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,6 @@ impl SnapshotDB {
.map_err(Into::into)
}

pub fn update_storage_log_entry(&self, key: &[u8], value: &[u8]) -> Result<()> {
// Unwrapping column family handle here is safe because presence of
// those CFs is ensured in construction of this DB.
let storage_logs = self.cf_handle(STORAGE_LOGS).unwrap();
let entry_bs = self.get_cf(storage_logs, key)?.unwrap();
let mut entry: SnapshotStorageLog = bincode::deserialize(&entry_bs)?;
entry.value = H256::from(<&[u8; 32]>::try_from(value).unwrap());
self.put_cf(storage_logs, key, bincode::serialize(&entry)?)
.map_err(Into::into)
}

pub fn insert_factory_dep(&self, fdep: &SnapshotFactoryDependency) -> Result<()> {
// Unwrapping column family handle here is safe because presence of
// those CFs is ensured in construction of this DB.
Expand Down
18 changes: 7 additions & 11 deletions src/processor/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,13 @@ fn reconstruct_genesis_state(database: &mut SnapshotDB, path: &str) -> Result<()
let key = U256::from_little_endian(&derived_key);
let value = H256::from(tmp);

if database.get_storage_log(&derived_key)?.is_none() {
database.insert_storage_log(&mut SnapshotStorageLog {
key,
value,
miniblock_number_of_initial_write: MiniblockNumber::from(miniblock_number),
l1_batch_number_of_initial_write: U64::from(ethereum::GENESIS_BLOCK),
enumeration_index: 0,
})?;
} else {
database.update_storage_log_entry(&derived_key, value.as_bytes())?;
}
database.insert_storage_log(&mut SnapshotStorageLog {
key,
value,
miniblock_number_of_initial_write: MiniblockNumber::from(miniblock_number),
l1_batch_number_of_initial_write: U64::from(ethereum::GENESIS_BLOCK),
enumeration_index: 0,
})?;
}

Ok(())
Expand Down

0 comments on commit fa16ca6

Please sign in to comment.