Skip to content

Commit

Permalink
deprecate GrowingStore and RevertibleStore (#182)
Browse files Browse the repository at this point in the history
* add deprecation note

* add comment

* apply suggestions from code review

Co-authored-by: Sean Chen <seanchen11235@gmail.com>

* nit

* mention InMemoryStore as alternative

---------

Co-authored-by: Sean Chen <seanchen11235@gmail.com>
  • Loading branch information
rnbguy and seanchen1991 authored May 10, 2024
1 parent 2dd5b95 commit cd793b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions basecoin/store/src/impls/growing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ use crate::types::{Height, Path};
/// If the path is deleted, the stored value is []
/// Note: we should not allow empty vec to store as
/// this would conflict with the deletion representation.
#[deprecated(
since = "TBD",
note = "GrowingStore does not implement deletion. Use InMemoryStore which implements deletion of AVL tree nodes."
)]
#[derive(Clone, Debug)]
pub struct GrowingStore<S> {
store: S,
Expand Down
10 changes: 10 additions & 0 deletions basecoin/store/src/impls/revertible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ use crate::types::{Height, Path};
/// an overwriting `set` doesn't reorganize a Merkle tree - but non-overwriting `set` and `delete`
/// operations may reorganize a Merkle tree - which may change the root hash. However, a Merkle
/// store should have no effect on a failed transaction.
#[deprecated(
since = "TBD",
note = "RevertibleStore has a bug where using the operation log to revert changes does not guarantee deterministic Merkle root hashes. Use InMemoryStore which implements a correct rollback procedure."
)]
#[derive(Clone, Debug)]
pub struct RevertibleStore<S> {
/// backing store
Expand Down Expand Up @@ -95,6 +99,12 @@ where
Ok(())
}

/// Revert all operations in the operation log.
///
/// This method doesn't guarantee that the Merkle tree will be reverted to the correct previous root hash.
/// It should be avoided. Use `InMemoryStore` directly which implements a correct rollback procedure.
///
/// GH issue: informalsystems/basecoin-rs#129
#[inline]
fn reset(&mut self) {
// note that we do NOT call the backing store's reset here - this allows users to create
Expand Down

0 comments on commit cd793b8

Please sign in to comment.