-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* temp work * temp work * fmt * more work * more work * finish of versioning * finish of versioning * fixed debugger
- Loading branch information
1 parent
4035d34
commit 8ada131
Showing
100 changed files
with
8,319 additions
and
3,908 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ members = [ | |
"visualize", | ||
"path", | ||
"grovedbg-types", | ||
"grovedb-version" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "grovedb-version" | ||
authors = ["Samuel Westrich <[email protected]>"] | ||
description = "Versioning library for Platform" | ||
version = "1.0.0-rc.2" | ||
edition = "2021" | ||
license = "MIT" | ||
|
||
[dependencies] | ||
thiserror = { version = "1.0.59" } | ||
versioned-feature-core = { git = "https://github.com/dashpay/versioned-feature-core", version = "1.0.0" } | ||
|
||
[features] | ||
mock-versions = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use thiserror::Error; | ||
use versioned_feature_core::FeatureVersion; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum GroveVersionError { | ||
/// Expected some specific versions | ||
#[error("grove unknown version on {method}, received: {received}")] | ||
UnknownVersionMismatch { | ||
/// method | ||
method: String, | ||
/// the allowed versions for this method | ||
known_versions: Vec<FeatureVersion>, | ||
/// requested core height | ||
received: FeatureVersion, | ||
}, | ||
|
||
/// Expected some specific versions | ||
#[error("{method} not active for grove version")] | ||
VersionNotActive { | ||
/// method | ||
method: String, | ||
/// the allowed versions for this method | ||
known_versions: Vec<FeatureVersion>, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
use crate::version::GroveVersion; | ||
|
||
pub mod error; | ||
pub mod version; | ||
|
||
#[macro_export] | ||
macro_rules! check_grovedb_v0_with_cost { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()) | ||
.wrap_with_cost(OperationCost::default()); | ||
} | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! check_grovedb_v0 { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()); | ||
} | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! check_merk_v0_with_cost { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()) | ||
.wrap_with_cost(OperationCost::default()); | ||
} | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! check_merk_v0 { | ||
($method:expr, $version:expr) => {{ | ||
const EXPECTED_VERSION: u16 = 0; | ||
if $version != EXPECTED_VERSION { | ||
return Err(GroveVersionError::UnknownVersionMismatch { | ||
method: $method.to_string(), | ||
known_versions: vec![EXPECTED_VERSION], | ||
received: $version, | ||
} | ||
.into()); | ||
} | ||
}}; | ||
} | ||
|
||
pub trait TryFromVersioned<T>: Sized { | ||
/// The type returned in the event of a conversion error. | ||
type Error; | ||
|
||
/// Performs the conversion. | ||
fn try_from_versioned(value: T, grove_version: &GroveVersion) -> Result<Self, Self::Error>; | ||
} | ||
|
||
pub trait TryIntoVersioned<T>: Sized { | ||
/// The type returned in the event of a conversion error. | ||
type Error; | ||
|
||
/// Performs the conversion. | ||
fn try_into_versioned(self, grove_version: &GroveVersion) -> Result<T, Self::Error>; | ||
} | ||
|
||
impl<T, U> TryIntoVersioned<U> for T | ||
where | ||
U: TryFromVersioned<T>, | ||
{ | ||
type Error = U::Error; | ||
|
||
#[inline] | ||
fn try_into_versioned(self, grove_version: &GroveVersion) -> Result<U, U::Error> { | ||
U::try_from_versioned(self, grove_version) | ||
} | ||
} | ||
|
||
impl<T, U> TryFromVersioned<U> for T | ||
where | ||
T: TryFrom<U>, | ||
{ | ||
type Error = T::Error; | ||
|
||
#[inline] | ||
fn try_from_versioned(value: U, _grove_version: &GroveVersion) -> Result<Self, Self::Error> { | ||
T::try_from(value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
use versioned_feature_core::FeatureVersion; | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBVersions { | ||
pub apply_batch: GroveDBApplyBatchVersions, | ||
pub element: GroveDBElementMethodVersions, | ||
pub operations: GroveDBOperationsVersions, | ||
pub path_query_methods: GroveDBPathQueryMethodVersions, | ||
pub replication: GroveDBReplicationVersions, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBPathQueryMethodVersions { | ||
pub terminal_keys: FeatureVersion, | ||
pub merge: FeatureVersion, | ||
pub query_items_at_path: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBApplyBatchVersions { | ||
pub apply_batch_structure: FeatureVersion, | ||
pub apply_body: FeatureVersion, | ||
pub continue_partial_apply_body: FeatureVersion, | ||
pub apply_operations_without_batching: FeatureVersion, | ||
pub apply_batch: FeatureVersion, | ||
pub apply_partial_batch: FeatureVersion, | ||
pub open_batch_transactional_merk_at_path: FeatureVersion, | ||
pub open_batch_merk_at_path: FeatureVersion, | ||
pub apply_batch_with_element_flags_update: FeatureVersion, | ||
pub apply_partial_batch_with_element_flags_update: FeatureVersion, | ||
pub estimated_case_operations_for_batch: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsVersions { | ||
pub get: GroveDBOperationsGetVersions, | ||
pub insert: GroveDBOperationsInsertVersions, | ||
pub delete: GroveDBOperationsDeleteVersions, | ||
pub delete_up_tree: GroveDBOperationsDeleteUpTreeVersions, | ||
pub query: GroveDBOperationsQueryVersions, | ||
pub proof: GroveDBOperationsProofVersions, | ||
pub average_case: GroveDBOperationsAverageCaseVersions, | ||
pub worst_case: GroveDBOperationsWorstCaseVersions, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsGetVersions { | ||
pub get: FeatureVersion, | ||
pub get_caching_optional: FeatureVersion, | ||
pub follow_reference: FeatureVersion, | ||
pub get_raw: FeatureVersion, | ||
pub get_raw_caching_optional: FeatureVersion, | ||
pub get_raw_optional: FeatureVersion, | ||
pub get_raw_optional_caching_optional: FeatureVersion, | ||
pub has_raw: FeatureVersion, | ||
pub check_subtree_exists_invalid_path: FeatureVersion, | ||
pub average_case_for_has_raw: FeatureVersion, | ||
pub average_case_for_has_raw_tree: FeatureVersion, | ||
pub average_case_for_get_raw: FeatureVersion, | ||
pub average_case_for_get: FeatureVersion, | ||
pub average_case_for_get_tree: FeatureVersion, | ||
pub worst_case_for_has_raw: FeatureVersion, | ||
pub worst_case_for_get_raw: FeatureVersion, | ||
pub worst_case_for_get: FeatureVersion, | ||
pub is_empty_tree: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsProofVersions { | ||
pub prove_query: FeatureVersion, | ||
pub prove_query_many: FeatureVersion, | ||
pub verify_query_with_options: FeatureVersion, | ||
pub verify_query_raw: FeatureVersion, | ||
pub verify_layer_proof: FeatureVersion, | ||
pub verify_query: FeatureVersion, | ||
pub verify_subset_query: FeatureVersion, | ||
pub verify_query_with_absence_proof: FeatureVersion, | ||
pub verify_subset_query_with_absence_proof: FeatureVersion, | ||
pub verify_query_with_chained_path_queries: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsQueryVersions { | ||
pub query_encoded_many: FeatureVersion, | ||
pub query_many_raw: FeatureVersion, | ||
pub get_proved_path_query: FeatureVersion, | ||
pub query: FeatureVersion, | ||
pub query_item_value: FeatureVersion, | ||
pub query_item_value_or_sum: FeatureVersion, | ||
pub query_sums: FeatureVersion, | ||
pub query_raw: FeatureVersion, | ||
pub query_keys_optional: FeatureVersion, | ||
pub query_raw_keys_optional: FeatureVersion, | ||
pub follow_element: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsAverageCaseVersions { | ||
pub add_average_case_get_merk_at_path: FeatureVersion, | ||
pub average_case_merk_replace_tree: FeatureVersion, | ||
pub average_case_merk_insert_tree: FeatureVersion, | ||
pub average_case_merk_delete_tree: FeatureVersion, | ||
pub average_case_merk_insert_element: FeatureVersion, | ||
pub average_case_merk_replace_element: FeatureVersion, | ||
pub average_case_merk_patch_element: FeatureVersion, | ||
pub average_case_merk_delete_element: FeatureVersion, | ||
pub add_average_case_has_raw_cost: FeatureVersion, | ||
pub add_average_case_has_raw_tree_cost: FeatureVersion, | ||
pub add_average_case_get_raw_cost: FeatureVersion, | ||
pub add_average_case_get_raw_tree_cost: FeatureVersion, | ||
pub add_average_case_get_cost: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsWorstCaseVersions { | ||
pub add_worst_case_get_merk_at_path: FeatureVersion, | ||
pub worst_case_merk_replace_tree: FeatureVersion, | ||
pub worst_case_merk_insert_tree: FeatureVersion, | ||
pub worst_case_merk_delete_tree: FeatureVersion, | ||
pub worst_case_merk_insert_element: FeatureVersion, | ||
pub worst_case_merk_replace_element: FeatureVersion, | ||
pub worst_case_merk_patch_element: FeatureVersion, | ||
pub worst_case_merk_delete_element: FeatureVersion, | ||
pub add_worst_case_has_raw_cost: FeatureVersion, | ||
pub add_worst_case_get_raw_tree_cost: FeatureVersion, | ||
pub add_worst_case_get_raw_cost: FeatureVersion, | ||
pub add_worst_case_get_cost: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsInsertVersions { | ||
pub insert: FeatureVersion, | ||
pub insert_on_transaction: FeatureVersion, | ||
pub insert_without_transaction: FeatureVersion, | ||
pub add_element_on_transaction: FeatureVersion, | ||
pub add_element_without_transaction: FeatureVersion, | ||
pub insert_if_not_exists: FeatureVersion, | ||
pub insert_if_changed_value: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsDeleteVersions { | ||
pub delete: FeatureVersion, | ||
pub clear_subtree: FeatureVersion, | ||
pub delete_with_sectional_storage_function: FeatureVersion, | ||
pub delete_if_empty_tree: FeatureVersion, | ||
pub delete_if_empty_tree_with_sectional_storage_function: FeatureVersion, | ||
pub delete_operation_for_delete_internal: FeatureVersion, | ||
pub delete_internal_on_transaction: FeatureVersion, | ||
pub delete_internal_without_transaction: FeatureVersion, | ||
pub average_case_delete_operation_for_delete: FeatureVersion, | ||
pub worst_case_delete_operation_for_delete: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsDeleteUpTreeVersions { | ||
pub delete_up_tree_while_empty: FeatureVersion, | ||
pub delete_up_tree_while_empty_with_sectional_storage: FeatureVersion, | ||
pub delete_operations_for_delete_up_tree_while_empty: FeatureVersion, | ||
pub add_delete_operations_for_delete_up_tree_while_empty: FeatureVersion, | ||
pub average_case_delete_operations_for_delete_up_tree_while_empty: FeatureVersion, | ||
pub worst_case_delete_operations_for_delete_up_tree_while_empty: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBOperationsApplyBatchVersions { | ||
pub apply_batch_structure: FeatureVersion, | ||
pub apply_body: FeatureVersion, | ||
pub continue_partial_apply_body: FeatureVersion, | ||
pub apply_operations_without_batching: FeatureVersion, | ||
pub apply_batch: FeatureVersion, | ||
pub apply_partial_batch: FeatureVersion, | ||
pub open_batch_transactional_merk_at_path: FeatureVersion, | ||
pub open_batch_merk_at_path: FeatureVersion, | ||
pub apply_batch_with_element_flags_update: FeatureVersion, | ||
pub apply_partial_batch_with_element_flags_update: FeatureVersion, | ||
pub estimated_case_operations_for_batch: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBElementMethodVersions { | ||
pub delete: FeatureVersion, | ||
pub delete_with_sectioned_removal_bytes: FeatureVersion, | ||
pub delete_into_batch_operations: FeatureVersion, | ||
pub element_at_key_already_exists: FeatureVersion, | ||
pub get: FeatureVersion, | ||
pub get_optional: FeatureVersion, | ||
pub get_from_storage: FeatureVersion, | ||
pub get_optional_from_storage: FeatureVersion, | ||
pub get_with_absolute_refs: FeatureVersion, | ||
pub get_value_hash: FeatureVersion, | ||
pub get_specialized_cost: FeatureVersion, | ||
pub value_defined_cost: FeatureVersion, | ||
pub value_defined_cost_for_serialized_value: FeatureVersion, | ||
pub specialized_costs_for_key_value: FeatureVersion, | ||
pub required_item_space: FeatureVersion, | ||
pub insert: FeatureVersion, | ||
pub insert_into_batch_operations: FeatureVersion, | ||
pub insert_if_not_exists: FeatureVersion, | ||
pub insert_if_not_exists_into_batch_operations: FeatureVersion, | ||
pub insert_if_changed_value: FeatureVersion, | ||
pub insert_if_changed_value_into_batch_operations: FeatureVersion, | ||
pub insert_reference: FeatureVersion, | ||
pub insert_reference_into_batch_operations: FeatureVersion, | ||
pub insert_subtree: FeatureVersion, | ||
pub insert_subtree_into_batch_operations: FeatureVersion, | ||
pub get_query: FeatureVersion, | ||
pub get_query_values: FeatureVersion, | ||
pub get_query_apply_function: FeatureVersion, | ||
pub get_path_query: FeatureVersion, | ||
pub get_sized_query: FeatureVersion, | ||
pub path_query_push: FeatureVersion, | ||
pub query_item: FeatureVersion, | ||
pub basic_push: FeatureVersion, | ||
pub serialize: FeatureVersion, | ||
pub serialized_size: FeatureVersion, | ||
pub deserialize: FeatureVersion, | ||
} | ||
|
||
#[derive(Clone, Debug, Default)] | ||
pub struct GroveDBReplicationVersions { | ||
pub get_subtrees_metadata: FeatureVersion, | ||
pub fetch_chunk: FeatureVersion, | ||
pub start_snapshot_syncing: FeatureVersion, | ||
pub apply_chunk: FeatureVersion, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[derive(Clone, Debug, Default)] | ||
pub struct MerkVersions {} |
Oops, something went wrong.