Skip to content

Commit 77e386b

Browse files
clabbyAmp
andauthored
[storage] require explicit Strategy generics (#3751)
Co-authored-by: Amp <noreply@ampcode.com>
1 parent 09bc3cc commit 77e386b

65 files changed

Lines changed: 1174 additions & 671 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/sync/src/databases/any.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ use std::{future::Future, num::NonZeroU64};
2424
use tracing::error;
2525

2626
/// Database type alias.
27-
pub type Database<E> = Db<mmr::Family, E, Key, Value, Hasher, Translator>;
27+
pub type Database<E> = Db<mmr::Family, E, Key, Value, Hasher, Translator, Sequential>;
2828

2929
/// Operation type alias.
3030
pub type Operation = FixedOperation<mmr::Family, Key, Value>;
3131

3232
/// Create a database configuration for use in tests.
33-
pub fn create_config(context: &impl BufferPooler) -> Config<Translator> {
33+
pub fn create_config(context: &impl BufferPooler) -> Config<Translator, Sequential> {
3434
let page_cache = buffer::paged::CacheRef::from_pooler(context, NZU16!(2048), NZUsize!(10));
3535
Config {
3636
merkle_config: MmrConfig {

examples/sync/src/databases/current.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,22 @@ use tracing::error;
3737
const CHUNK_SIZE: usize = sha256::Digest::SIZE;
3838

3939
/// Database type alias.
40-
pub type Database<E> =
41-
current::unordered::fixed::Db<mmr::Family, E, Key, Value, Hasher, Translator, CHUNK_SIZE>;
40+
pub type Database<E> = current::unordered::fixed::Db<
41+
mmr::Family,
42+
E,
43+
Key,
44+
Value,
45+
Hasher,
46+
Translator,
47+
CHUNK_SIZE,
48+
Sequential,
49+
>;
4250

4351
/// Operation type alias. Same as the `any` operation type.
4452
pub type Operation = FixedOperation<mmr::Family, Key, Value>;
4553

4654
/// Create a database configuration.
47-
pub fn create_config(context: &impl BufferPooler) -> Config<Translator> {
55+
pub fn create_config(context: &impl BufferPooler) -> Config<Translator, Sequential> {
4856
let page_cache = buffer::paged::CacheRef::from_pooler(context, NZU16!(2048), NZUsize!(10));
4957
Config {
5058
merkle_config: MmrConfig {

examples/sync/src/databases/immutable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ use std::{future::Future, num::NonZeroU64};
2121
use tracing::error;
2222

2323
/// Database type alias.
24-
pub type Database<E> = fixed::Db<mmr::Family, E, Key, Value, Hasher, Translator>;
24+
pub type Database<E> = fixed::Db<mmr::Family, E, Key, Value, Hasher, Translator, Sequential>;
2525

2626
/// Operation type alias.
2727
pub type Operation = fixed::Operation<mmr::Family, Key, Value>;
2828

2929
/// Create a database configuration with appropriate partitioning for Immutable.
30-
pub fn create_config(context: &impl BufferPooler) -> Config<Translator, FConfig> {
30+
pub fn create_config(context: &impl BufferPooler) -> Config<Translator, FConfig, Sequential> {
3131
let page_cache = commonware_runtime::buffer::paged::CacheRef::from_pooler(
3232
context,
3333
NZU16!(2048),

examples/sync/src/databases/immutable_compact.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ use commonware_storage::{
1717
use tracing::error;
1818

1919
/// Database type alias.
20-
pub type Database<E> = fixed::CompactDb<mmr::Family, E, Key, Value, Hasher>;
20+
pub type Database<E> = fixed::CompactDb<mmr::Family, E, Key, Value, Hasher, Sequential>;
2121

2222
/// Operation type alias.
2323
pub type Operation = fixed::Operation<mmr::Family, Key, Value>;
2424

2525
/// Create a database configuration for the compact immutable variant.
26-
pub fn create_config(_context: &impl BufferPooler) -> CompactConfig {
26+
pub fn create_config(_context: &impl BufferPooler) -> CompactConfig<Sequential> {
2727
CompactConfig {
2828
merkle: MerkleConfig {
2929
partition: "compact-immutable".into(),

examples/sync/src/databases/keyless.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ use std::num::NonZeroU64;
2727
use tracing::error;
2828

2929
/// Database type alias.
30-
pub type Database<E> = fixed::Db<mmr::Family, E, Value, Hasher>;
30+
pub type Database<E> = fixed::Db<mmr::Family, E, Value, Hasher, Sequential>;
3131

3232
/// Operation type alias.
3333
pub type Operation = fixed::Operation<mmr::Family, Value>;
3434

3535
/// Create a database configuration for the keyless variant.
36-
pub fn create_config(context: &impl BufferPooler) -> fixed::Config {
36+
pub fn create_config(context: &impl BufferPooler) -> fixed::Config<Sequential> {
3737
let page_cache = buffer::paged::CacheRef::from_pooler(context, NZU16!(2048), NZUsize!(10));
3838
keyless::Config {
3939
merkle: MmrConfig {

examples/sync/src/databases/keyless_compact.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ use commonware_storage::{
1717
use tracing::error;
1818

1919
/// Database type alias.
20-
pub type Database<E> = fixed::CompactDb<mmr::Family, E, Value, Hasher>;
20+
pub type Database<E> = fixed::CompactDb<mmr::Family, E, Value, Hasher, Sequential>;
2121

2222
/// Operation type alias.
2323
pub type Operation = fixed::Operation<mmr::Family, Value>;
2424

2525
/// Create a database configuration for the compact keyless variant.
26-
pub fn create_config(_context: &impl BufferPooler) -> CompactConfig {
26+
pub fn create_config(_context: &impl BufferPooler) -> CompactConfig<Sequential> {
2727
CompactConfig {
2828
merkle: MerkleConfig {
2929
partition: "compact-keyless".into(),

storage/fuzz/fuzz_targets/current_crash_recovery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type RawValue = [u8; 32];
3838
/// Maximum write buffer size.
3939
const MAX_WRITE_BUF: usize = 2048;
4040

41-
type Db<F> = Current<F, deterministic::Context, Key, Value, Sha256, TwoCap, 32>;
41+
type Db<F> = Current<F, deterministic::Context, Key, Value, Sha256, TwoCap, 32, Sequential>;
4242

4343
fn bounded_page_size(u: &mut Unstructured<'_>) -> Result<u16> {
4444
u.int_in_range(1..=256)
@@ -99,7 +99,7 @@ fn make_config(
9999
merkle_items_per_blob: u64,
100100
log_items_per_blob: u64,
101101
write_buffer: NonZeroUsize,
102-
) -> VariableConfig<TwoCap, ((), ())> {
102+
) -> VariableConfig<TwoCap, ((), ()), Sequential> {
103103
let page_cache = CacheRef::from_pooler(ctx, page_size, page_cache_size);
104104
VariableConfig {
105105
merkle_config: MerkleConfig {

storage/fuzz/fuzz_targets/current_mmb_prune_grow.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ type Key = FixedBytes<1>;
3333
type Value = FixedBytes<32>;
3434
type LogicalKey = u8;
3535
type RawValue = [u8; 32];
36-
type Db = CurrentDb<mmb::Family, deterministic::Context, Key, Value, Sha256, TwoCap, 32>;
36+
type Db =
37+
CurrentDb<mmb::Family, deterministic::Context, Key, Value, Sha256, TwoCap, 32, Sequential>;
3738

3839
#[derive(Arbitrary, Debug, Clone)]
3940
enum CurrentOperation {
@@ -145,7 +146,7 @@ const MERKLE_ITEMS_PER_BLOB: u64 = 11;
145146
const LOG_ITEMS_PER_BLOB: u64 = 7;
146147
const WRITE_BUFFER_SIZE: usize = 1024;
147148

148-
fn test_config(name: &str, page_cache: CacheRef) -> Config<TwoCap> {
149+
fn test_config(name: &str, page_cache: CacheRef) -> Config<TwoCap, Sequential> {
149150
Config {
150151
merkle_config: MerkleConfig {
151152
journal_partition: format!("fuzz-current-mmb-pruning-{name}-merkle-journal"),
@@ -225,7 +226,7 @@ async fn prune_to_floor(db: &mut Db, reference_db: &Db, context: &str) {
225226
async fn reopen_pruned_db(
226227
db: Db,
227228
context: &deterministic::Context,
228-
config: &Config<TwoCap>,
229+
config: &Config<TwoCap, Sequential>,
229230
reference_db: &Db,
230231
reopen_count: usize,
231232
) -> Db {
@@ -301,7 +302,7 @@ async fn bootstrap_pruned_state(
301302

302303
struct ReopenEnv<'a> {
303304
context: &'a deterministic::Context,
304-
config: &'a Config<TwoCap>,
305+
config: &'a Config<TwoCap, Sequential>,
305306
count: &'a mut usize,
306307
}
307308

storage/fuzz/fuzz_targets/current_ordered_operations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Key = FixedBytes<32>;
2424
type Value = FixedBytes<32>;
2525
type RawKey = [u8; 32];
2626
type RawValue = [u8; 32];
27-
type Db<F> = CurrentDb<F, deterministic::Context, Key, Value, Sha256, TwoCap, 32>;
27+
type Db<F> = CurrentDb<F, deterministic::Context, Key, Value, Sha256, TwoCap, 32, Sequential>;
2828

2929
#[derive(Arbitrary, Debug, Clone)]
3030
enum CurrentOperation {

storage/fuzz/fuzz_targets/current_unordered_batch_root.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::num::NonZeroU16;
1818

1919
type Key = FixedBytes<32>;
2020
type Value = FixedBytes<32>;
21-
type Db<F> = CurrentDb<F, deterministic::Context, Key, Value, Sha256, OneCap, 32>;
21+
type Db<F> = CurrentDb<F, deterministic::Context, Key, Value, Sha256, OneCap, 32, Sequential>;
2222

2323
const PAGE_SIZE: NonZeroU16 = NZU16!(137);
2424
const COLLISION_GROUPS: u8 = 4;
@@ -76,7 +76,7 @@ impl<'a> Arbitrary<'a> for FuzzInput {
7676
}
7777
}
7878

79-
fn test_config(name: &str, pooler: &impl BufferPooler) -> Config<OneCap> {
79+
fn test_config(name: &str, pooler: &impl BufferPooler) -> Config<OneCap, Sequential> {
8080
let page_cache = CacheRef::from_pooler(pooler, PAGE_SIZE, NZUsize!(2));
8181
Config {
8282
merkle_config: MerkleConfig {

0 commit comments

Comments
 (0)