Skip to content

Commit

Permalink
update dependencies and small cleanup (#350)
Browse files Browse the repository at this point in the history
* reduce dependency tree

* downgraded axum

* downgraded axum

* downgraded axum

* a fix
  • Loading branch information
QuantumExplorer authored Jan 14, 2025
1 parent c8108a2 commit 6a7643e
Show file tree
Hide file tree
Showing 87 changed files with 954 additions and 920 deletions.
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 @@ -256,13 +256,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 @@ -274,7 +274,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 @@ -736,10 +736,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 @@ -764,19 +764,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 @@ -788,7 +786,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 @@ -1185,7 +1183,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 @@ -1197,7 +1195,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 @@ -1242,9 +1240,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 @@ -1281,15 +1279,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 @@ -1306,15 +1304,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 @@ -1336,7 +1334,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 @@ -1357,7 +1355,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 @@ -1367,7 +1365,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 @@ -1388,7 +1386,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 @@ -1398,7 +1396,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 @@ -1427,15 +1425,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 @@ -1456,7 +1454,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 @@ -1466,7 +1464,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 @@ -1487,7 +1485,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 @@ -1497,7 +1495,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 @@ -1551,7 +1549,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 @@ -1570,7 +1568,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 @@ -1580,7 +1578,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

0 comments on commit 6a7643e

Please sign in to comment.