Skip to content

Commit d50f517

Browse files
halfpriceclaude
andcommitted
feat: implement V2 blob info with storage pool support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 50f7263 commit d50f517

3 files changed

Lines changed: 952 additions & 1027 deletions

File tree

crates/walrus-service/src/node/storage/blob_info/blob_info_v1.rs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl ValidBlobInfoV1 {
310310

311311
/// Processes a register status change on the [`Option<PermanentBlobInfoV1>`] object
312312
/// representing all permanent blobs.
313-
fn register_permanent(
313+
pub(crate) fn register_permanent(
314314
permanent_total: &mut Option<PermanentBlobInfoV1>,
315315
change_info: &BlobStatusChangeInfo,
316316
) {
@@ -321,7 +321,7 @@ impl ValidBlobInfoV1 {
321321
/// and the certified permanent blobs.
322322
///
323323
/// Returns whether the update was successful.
324-
fn certify_permanent(
324+
pub(crate) fn certify_permanent(
325325
permanent_total: &Option<PermanentBlobInfoV1>,
326326
permanent_certified: &mut Option<PermanentBlobInfoV1>,
327327
change_info: &BlobStatusChangeInfo,
@@ -356,7 +356,7 @@ impl ValidBlobInfoV1 {
356356

357357
/// Processes an extend status change on the [`PermanentBlobInfoV1`] object representing the
358358
/// certified permanent blobs.
359-
fn extend_permanent(
359+
pub(crate) fn extend_permanent(
360360
permanent_info: &mut Option<PermanentBlobInfoV1>,
361361
change_info: &BlobStatusChangeInfo,
362362
) {
@@ -380,7 +380,7 @@ impl ValidBlobInfoV1 {
380380
self.maybe_unset_initial_certified_epoch();
381381
}
382382

383-
fn decrement_blob_info_inner(blob_info_inner: &mut Option<PermanentBlobInfoV1>) {
383+
pub(crate) fn decrement_blob_info_inner(blob_info_inner: &mut Option<PermanentBlobInfoV1>) {
384384
match blob_info_inner {
385385
None => tracing::error!("attempt to delete a permanent blob when none is tracked"),
386386
Some(PermanentBlobInfoV1 { count, .. }) => {
@@ -472,7 +472,7 @@ impl PermanentBlobInfoV1 {
472472
/// # Panics
473473
///
474474
/// Panics if the change info has `deletable == true`.
475-
fn update(&mut self, change_info: &BlobStatusChangeInfo, increase_count: bool) {
475+
pub(crate) fn update(&mut self, change_info: &BlobStatusChangeInfo, increase_count: bool) {
476476
assert!(!change_info.deletable);
477477

478478
if increase_count {
@@ -514,7 +514,7 @@ impl PermanentBlobInfoV1 {
514514
}
515515

516516
#[cfg(test)]
517-
fn new_fixed_for_testing(count: u32, end_epoch: Epoch, event_seq: u64) -> Self {
517+
pub(crate) fn new_fixed_for_testing(count: u32, end_epoch: Epoch, event_seq: u64) -> Self {
518518
Self {
519519
count: NonZeroU32::new(count).expect("count must be non-zero"),
520520
end_epoch,
@@ -523,7 +523,7 @@ impl PermanentBlobInfoV1 {
523523
}
524524

525525
#[cfg(test)]
526-
fn new_for_testing(count: u32, end_epoch: Epoch) -> Self {
526+
pub(crate) fn new_for_testing(count: u32, end_epoch: Epoch) -> Self {
527527
Self {
528528
count: NonZeroU32::new(count).expect("count must be non-zero"),
529529
end_epoch,
@@ -664,6 +664,11 @@ impl Mergeable for BlobInfoV1 {
664664
Self::Valid(valid_blob_info),
665665
BlobInfoMergeOperand::PermanentExpired { was_certified },
666666
) => valid_blob_info.permanent_expired(was_certified),
667+
// Pool operands should never reach V1 — they are intercepted at the BlobInfo level.
668+
(_, BlobInfoMergeOperand::PooledBlobChangeStatus { .. })
669+
| (_, BlobInfoMergeOperand::PoolExpired { .. }) => {
670+
unreachable!("pool operands should be handled in BlobInfoV2")
671+
}
667672
}
668673
self
669674
}
@@ -732,10 +737,19 @@ impl Mergeable for BlobInfoV1 {
732737
);
733738
None
734739
}
740+
// Pool operands should never reach V1 — they are intercepted at the BlobInfo level.
741+
BlobInfoMergeOperand::PooledBlobChangeStatus { .. }
742+
| BlobInfoMergeOperand::PoolExpired { .. } => {
743+
unreachable!("pool operands should be handled in BlobInfoV2")
744+
}
735745
}
736746
}
737747
}
738748

749+
// =============================================================================
750+
// Per-object blob info V1
751+
// =============================================================================
752+
739753
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
740754
pub(crate) struct PerObjectBlobInfoV1 {
741755
/// The blob ID.
@@ -783,6 +797,10 @@ impl PerObjectBlobInfoApi for PerObjectBlobInfoV1 {
783797
fn is_deleted(&self) -> bool {
784798
self.deleted
785799
}
800+
801+
fn storage_pool_id(&self) -> Option<ObjectID> {
802+
None
803+
}
786804
}
787805

788806
impl ToBytes for PerObjectBlobInfoV1 {}

0 commit comments

Comments
 (0)