Skip to content

Commit

Permalink
fix an issue
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Oct 21, 2024
1 parent 71b91ac commit aa7e570
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
10 changes: 6 additions & 4 deletions crates/stages/stages/src/stages/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,12 @@ where
let time = Instant::now();

// write output
let (plain_state, _) =
state.bundle.clone().into_plain_state_and_reverts(OriginalValuesKnown::Yes);
let mut cache_writer = PlainCacheWriter::new(provider.tx_ref());
cache_writer.write_change_set(stage_progress, &plain_state);
if self.enable_cache {
let (plain_state, _) =
state.bundle.clone().into_plain_state_and_reverts(OriginalValuesKnown::Yes);
let mut cache_writer = PlainCacheWriter::new(provider.tx_ref());
cache_writer.write_change_set(stage_progress, &plain_state);
}

let mut writer = UnifiedStorageWriter::new(&provider, static_file_producer);
writer.write_to_storage(state, OriginalValuesKnown::Yes)?;
Expand Down
26 changes: 17 additions & 9 deletions crates/storage/provider/src/providers/state/cache/cache_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,25 @@ impl<'a, TX> PlainCacheWriter<'a, TX> {
// Update storage cache
for storage in &change_set.storage {
if storage.wipe_storage {
let walker = cursor.walk_dup(Some(storage.address), None).unwrap();
for kv in walker {
match kv {
Ok((k, v)) => {
super::plain_state::PLAIN_STORAGES.remove(&(k, v.key));
}
Err(_) => {
super::plain_state::PLAIN_STORAGES.clear();
break;
let walker = cursor.walk_dup(Some(storage.address), None);
match walker {
Ok(walker) => {
for kv in walker {
match kv {
Ok((k, v)) => {
super::plain_state::PLAIN_STORAGES.remove(&(k, v.key));
}
Err(_) => {
super::plain_state::PLAIN_STORAGES.clear();
break;
}
}
}
}
Err(_) => {
super::plain_state::PLAIN_STORAGES.clear();
break;
}
}
}

Expand Down

0 comments on commit aa7e570

Please sign in to comment.