Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies and small cleanup #350

Merged
merged 5 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions costs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ repository = "https://github.com/dashpay/grovedb"


[dependencies]
thiserror = "1.0.59"
intmap = "2.0.0"
thiserror = "2.0.11"
intmap = "3.0.1"
integer-encoding = "4.0.0"
8 changes: 4 additions & 4 deletions costs/src/storage_cost/removal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ use crate::storage_cost::removal::StorageRemovedBytes::{
pub type Identifier = [u8; 32];

/// Unknown Epoch
pub const UNKNOWN_EPOCH: u64 = u64::MAX;
pub const UNKNOWN_EPOCH: u16 = u16::MAX;

/// A BTreeMap mapping identities to the storage they removed by epoch
pub type StorageRemovalPerEpochByIdentifier = BTreeMap<Identifier, IntMap<u32>>;
pub type StorageRemovalPerEpochByIdentifier = BTreeMap<Identifier, IntMap<u16, u32>>;

/// Removal bytes
#[derive(Debug, PartialEq, Clone, Eq, Default)]
Expand Down Expand Up @@ -122,7 +122,7 @@ impl Add for StorageRemovedBytes {
};
(k, combined)
})
.collect::<IntMap<u32>>();
.collect::<IntMap<u16, u32>>();
intersection.into_iter().chain(int_map_b).collect()
} else {
int_map_b
Expand Down Expand Up @@ -193,7 +193,7 @@ impl AddAssign for StorageRemovedBytes {
};
(k, combined)
})
.collect::<IntMap<u32>>();
.collect::<IntMap<u16, u32>>();
intersection.into_iter().chain(int_map_b).collect()
} else {
int_map_b
Expand Down
4 changes: 2 additions & 2 deletions grovedb-epoch-based-storage-flags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ grovedb-costs = { version = "2.1.0", path = "../costs" }

hex = { version = "0.4.3" }
integer-encoding = { version = "4.0.0" }
intmap = { version = "2.0.0", features = ["serde"]}
thiserror = { version = "1.0.63" }
intmap = { version = "3.0.1", features = ["serde"]}
thiserror = { version = "2.0.11" }
70 changes: 34 additions & 36 deletions grovedb-epoch-based-storage-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ impl StorageFlags {
sectioned_bytes
.iter()
.try_for_each(|(epoch, removed_bytes)| {
if *epoch == base_epoch as u64 {
if epoch == base_epoch {
return Ok::<(), StorageFlagsError>(());
}
let bytes_added_in_epoch = other_epoch_bytes.get_mut(&(*epoch as u16)).ok_or(
let bytes_added_in_epoch = other_epoch_bytes.get_mut(&epoch).ok_or(
StorageFlagsError::RemovingAtEpochWithNoAssociatedStorage(format!(
"can not remove bytes when there is no epoch number [{}]",
*epoch
epoch
)),
)?;

Expand All @@ -273,7 +273,7 @@ impl StorageFlags {

if desired_bytes_in_epoch <= MINIMUM_NON_BASE_FLAGS_SIZE {
// Collect the key to remove later
keys_to_remove.push(*epoch as u16);
keys_to_remove.push(epoch);
} else {
*bytes_added_in_epoch = desired_bytes_in_epoch;
}
Expand Down Expand Up @@ -735,10 +735,10 @@ impl StorageFlags {
return NoStorageRemoval;
}
let bytes_left = removed_bytes;
let mut sectioned_storage_removal: IntMap<u32> = IntMap::default();
let mut sectioned_storage_removal: IntMap<u16, u32> = IntMap::default();
if bytes_left > 0 {
// We need to take some from the base epoch
sectioned_storage_removal.insert(*base_epoch as u64, removed_bytes);
sectioned_storage_removal.insert(*base_epoch, removed_bytes);
}
let mut sectioned_storage_removal_by_identifier: StorageRemovalPerEpochByIdentifier =
BTreeMap::new();
Expand All @@ -763,19 +763,17 @@ impl StorageFlags {
}
let mut bytes_left = removed_bytes;
let mut rev_iter = other_epoch_bytes.iter().rev();
let mut sectioned_storage_removal: IntMap<u32> = IntMap::default();
let mut sectioned_storage_removal: IntMap<u16, u32> = IntMap::default();

while bytes_left > 0 {
if let Some((epoch_index, bytes_in_epoch)) = rev_iter.next() {
if *bytes_in_epoch <= bytes_left + MINIMUM_NON_BASE_FLAGS_SIZE {
sectioned_storage_removal.insert(
*epoch_index as u64,
*bytes_in_epoch - MINIMUM_NON_BASE_FLAGS_SIZE,
);
sectioned_storage_removal
.insert(*epoch_index, *bytes_in_epoch - MINIMUM_NON_BASE_FLAGS_SIZE);
bytes_left -= *bytes_in_epoch - MINIMUM_NON_BASE_FLAGS_SIZE;
} else {
// Correctly take only the required bytes_left from this epoch
sectioned_storage_removal.insert(*epoch_index as u64, bytes_left);
sectioned_storage_removal.insert(*epoch_index, bytes_left);
bytes_left = 0; // All required bytes have been removed, stop processing
break; // Exit the loop as there's no need to process
// further epochs
Expand All @@ -787,7 +785,7 @@ impl StorageFlags {

if bytes_left > 0 {
// If there are still bytes left, take them from the base epoch
sectioned_storage_removal.insert(*base_epoch as u64, bytes_left);
sectioned_storage_removal.insert(*base_epoch, bytes_left);
}

let mut sectioned_storage_removal_by_identifier: StorageRemovalPerEpochByIdentifier =
Expand Down Expand Up @@ -1184,7 +1182,7 @@ mod storage_flags_tests {

fn single_epoch_removed_bytes_map(
owner_id: [u8; 32],
epoch_index: u64,
epoch_index: u16,
bytes_removed: u32,
) -> StorageRemovalPerEpochByIdentifier {
let mut removed_bytes = StorageRemovalPerEpochByIdentifier::default();
Expand All @@ -1196,7 +1194,7 @@ mod storage_flags_tests {

fn multi_epoch_removed_bytes_map(
owner_id: [u8; 32],
removed_bytes_per_epoch: IntMap<u32>,
removed_bytes_per_epoch: IntMap<u16, u32>,
) -> StorageRemovalPerEpochByIdentifier {
let mut removed_bytes = StorageRemovalPerEpochByIdentifier::default();
removed_bytes.insert(owner_id, removed_bytes_per_epoch);
Expand Down Expand Up @@ -1241,9 +1239,9 @@ mod storage_flags_tests {
let mut removed_bytes = IntMap::new();
for i in 1..200 {
other_epochs.insert(i, MINIMUM_NON_BASE_FLAGS_SIZE + 1);
removed_bytes.insert(i as u64, 1); // anything between 1 and
// MINIMUM_NON_BASE_FLAGS_SIZE +
// 1 would be the same
removed_bytes.insert(i, 1); // anything between 1 and
// MINIMUM_NON_BASE_FLAGS_SIZE +
// 1 would be the same
}

let left_flag = StorageFlags::MultiEpochOwned(left_base_index, other_epochs, owner_id);
Expand Down Expand Up @@ -1280,15 +1278,15 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(default_owner_id(), IntMap::from_iter([(5u64, 100)]));
map.insert(default_owner_id(), IntMap::from_iter([(5u16, 100)]));
map
})
);
assert_eq!(
value_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(default_owner_id(), IntMap::from_iter([(5u64, 200)]));
map.insert(default_owner_id(), IntMap::from_iter([(5u16, 200)]));
map
})
);
Expand All @@ -1305,15 +1303,15 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(owner_id, IntMap::from_iter([(5u64, 50)]));
map.insert(owner_id, IntMap::from_iter([(5u16, 50)]));
map
})
);
assert_eq!(
value_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(owner_id, IntMap::from_iter([(5u64, 150)]));
map.insert(owner_id, IntMap::from_iter([(5u16, 150)]));
map
})
);
Expand All @@ -1335,7 +1333,7 @@ mod storage_flags_tests {
let mut map = BTreeMap::new();
map.insert(
default_owner_id(),
IntMap::from_iter([(7u64, 197), (6u64, 53)]),
IntMap::from_iter([(7u16, 197), (6u16, 53)]),
);
map
})
Expand All @@ -1356,7 +1354,7 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(default_owner_id(), IntMap::from_iter([(5u64, 250)]));
map.insert(default_owner_id(), IntMap::from_iter([(5u16, 250)]));
map
})
);
Expand All @@ -1366,7 +1364,7 @@ mod storage_flags_tests {
let mut map = BTreeMap::new();
map.insert(
default_owner_id(),
IntMap::from_iter([(7u64, 47), (6u64, 97), (5u64, 106)]),
IntMap::from_iter([(7u16, 47), (6u16, 97), (5u16, 106)]),
);
map
})
Expand All @@ -1387,7 +1385,7 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(owner_id, IntMap::from_iter([(5u64, 250)]));
map.insert(owner_id, IntMap::from_iter([(5u16, 250)]));
map
})
);
Expand All @@ -1397,7 +1395,7 @@ mod storage_flags_tests {
let mut map = BTreeMap::new();
map.insert(
owner_id,
IntMap::from_iter([(7u64, 47), (6u64, 97), (5u64, 106)]),
IntMap::from_iter([(7u16, 47), (6u16, 97), (5u16, 106)]),
);
map
})
Expand Down Expand Up @@ -1426,15 +1424,15 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(owner_id, IntMap::from_iter([(5u64, 100)]));
map.insert(owner_id, IntMap::from_iter([(5u16, 100)]));
map
})
);
assert_eq!(
value_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(owner_id, IntMap::from_iter([(5u64, 50)]));
map.insert(owner_id, IntMap::from_iter([(5u16, 50)]));
map
})
);
Expand All @@ -1455,7 +1453,7 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(default_owner_id(), IntMap::from_iter([(5u64, 400)]));
map.insert(default_owner_id(), IntMap::from_iter([(5u16, 400)]));
map
})
);
Expand All @@ -1465,7 +1463,7 @@ mod storage_flags_tests {
let mut map = BTreeMap::new();
map.insert(
default_owner_id(),
IntMap::from_iter([(7u64, 197), (6u64, 97), (5u64, 6)]),
IntMap::from_iter([(7u16, 197), (6u16, 97), (5u16, 6)]),
);
map
})
Expand All @@ -1486,7 +1484,7 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(owner_id, IntMap::from_iter([(5u64, 450)]));
map.insert(owner_id, IntMap::from_iter([(5u16, 450)]));
map
})
);
Expand All @@ -1496,7 +1494,7 @@ mod storage_flags_tests {
let mut map = BTreeMap::new();
map.insert(
owner_id,
IntMap::from_iter([(7u64, 197), (6u64, 97), (5u64, 56)]),
IntMap::from_iter([(7u16, 197), (6u16, 97), (5u16, 56)]),
);
map
})
Expand Down Expand Up @@ -1550,7 +1548,7 @@ mod storage_flags_tests {
let mut map = BTreeMap::new();
map.insert(
owner_id,
IntMap::from_iter([(5u64, 6), (6u64, 297), (7u64, 397)]),
IntMap::from_iter([(5u16, 6), (6u16, 297), (7u16, 397)]),
);
map
})
Expand All @@ -1569,7 +1567,7 @@ mod storage_flags_tests {
key_removal,
StorageRemovedBytes::SectionedStorageRemoval({
let mut map = BTreeMap::new();
map.insert(default_owner_id(), IntMap::from_iter([(5u64, 400)]));
map.insert(default_owner_id(), IntMap::from_iter([(5u16, 400)]));
map
})
);
Expand All @@ -1579,7 +1577,7 @@ mod storage_flags_tests {
let mut map = BTreeMap::new();
map.insert(
default_owner_id(),
IntMap::from_iter([(7u64, 97), (6u64, 297), (5u64, 106)]),
IntMap::from_iter([(7u16, 97), (6u16, 297), (5u16, 106)]),
);
map
})
Expand Down
2 changes: 1 addition & 1 deletion grovedb-version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT"
repository = "https://github.com/dashpay/grovedb"

[dependencies]
thiserror = "1.0.59"
thiserror = "2.0.11"
versioned-feature-core = "1.0.0"

[features]
Expand Down
22 changes: 11 additions & 11 deletions grovedb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,20 @@ grovedb-storage = { version = "2.1.0", path = "../storage", optional = true }
grovedb-version = { version = "2.1.0", path = "../grovedb-version" }
grovedb-visualize = { version = "2.1.0", path = "../visualize", optional = true }

axum = { version = "0.7.5", features = ["macros"], optional = true }
axum = { version = "=0.7.5", features = ["macros"], optional = true }
bincode = { version = "2.0.0-rc.3" }
bitvec = "1"
blake3 = "1.4.0"
derive_more = "0.99.18"
blake3 = "1.5.5"
hex = "0.4.3"
indexmap = "2.2.6"
indexmap = "2.7.0"
integer-encoding = { version = "4.0.0", optional = true }
intmap = { version = "2.0.0", optional = true }
itertools = { version = "0.12.1", optional = true }
nohash-hasher = { version = "0.2.0", optional = true }
intmap = { version = "3.0.1", optional = true }
itertools = { version = "0.14.0", optional = true }
tempfile = { version = "3.10.1", optional = true }
thiserror = { version = "1.0.59", optional = true }
thiserror = { version = "2.0.11", optional = true }
tokio-util = { version = "0.7.12", optional = true }
tokio = { version = "1.40.0", features = ["rt-multi-thread", "net"], optional = true }
tower-http = { version = "0.5.2", features = ["fs"], optional = true }
zip-extensions = { version ="0.6.2", optional = true }
zip-extensions = { version = "0.8.1", optional = true }
serde = { version = "1.0.210", features = ["derive"], optional = true }

[dev-dependencies]
Expand All @@ -56,14 +53,17 @@ proof_debug = ["grovedb-merk/proof_debug"]
serde = ["dep:serde", "grovedb-merk/serde", "indexmap/serde"]
full = [
"grovedb-merk/full",
"minimal",
]
minimal = [
"grovedb-merk/minimal",
"thiserror",
"tempfile",
"grovedb-storage/rocksdb_storage",
"visualize",
"itertools",
"integer-encoding",
"grovedb-costs",
"nohash-hasher",
"intmap",
]
visualize = [
Expand Down
Loading
Loading