Skip to content

Commit f76df99

Browse files
committed
starknet_committer: delete patricia paths on reverts
1 parent 7d1b975 commit f76df99

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

crates/apollo_committer/src/committer.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,26 @@ where
398398
to {last_committed_block}"
399399
);
400400
block_measurements.start_measurement(Action::Write);
401-
let n_write_entries = self
402-
.forest_storage
403-
.write_with_metadata(&filled_forest, metadata, deleted_nodes)
404-
.await
405-
.map_err(|err| self.map_internal_error(err))?;
401+
let n_write_entries = {
402+
#[cfg(not(feature = "os_input"))]
403+
{
404+
self.forest_storage
405+
.write_with_metadata(&filled_forest, metadata, deleted_nodes)
406+
.await
407+
}
408+
#[cfg(feature = "os_input")]
409+
{
410+
self.forest_storage
411+
.write_with_metadata_and_witnesses(
412+
&filled_forest,
413+
metadata,
414+
deleted_nodes,
415+
PatriciaProofsUpdate::Delete(height),
416+
)
417+
.await
418+
}
419+
}
420+
.map_err(|err| self.map_internal_error(err))?;
406421
block_measurements.attempt_to_stop_measurement(Action::Write, n_write_entries).ok();
407422
block_measurements.attempt_to_stop_measurement(Action::EndToEnd, 0).ok();
408423
update_metrics(height, &block_measurements.block_measurement);

crates/starknet_committer/src/db/forest_trait.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,30 @@ impl<T> ForestReaderWithEmptyContext for T where
265265
///
266266
/// Types that require external context (e.g., `FactsDb` which needs roots provided externally as
267267
/// they are not part of the committer storage) should NOT implement this trait.
268+
#[cfg(not(feature = "os_input"))]
268269
pub trait ForestStorageWithEmptyReadContext:
269270
ForestReaderWithEmptyContext + ForestWriterWithMetadata + StorageInitializer
270271
{
271272
}
272273

274+
#[cfg(not(feature = "os_input"))]
273275
impl<T> ForestStorageWithEmptyReadContext for T where
274276
T: ForestReaderWithEmptyContext + ForestWriterWithMetadata + StorageInitializer
275277
{
276278
}
279+
280+
#[cfg(feature = "os_input")]
281+
pub trait ForestStorageWithEmptyReadContext:
282+
ForestReaderWithEmptyContext
283+
+ forest_trait_witnesses::ForestWriterWithMetadataAndWitnesses
284+
+ StorageInitializer
285+
{
286+
}
287+
288+
#[cfg(feature = "os_input")]
289+
impl<T> ForestStorageWithEmptyReadContext for T where
290+
T: ForestReaderWithEmptyContext
291+
+ forest_trait_witnesses::ForestWriterWithMetadataAndWitnesses
292+
+ StorageInitializer
293+
{
294+
}

0 commit comments

Comments
 (0)