Skip to content

Misleading comment on Batch.Immutable field #5334

@crtahlin

Description

@crtahlin

The comment on the Immutable field in the Batch struct says:

https://github.com/ethersphere/bee/blob/master/pkg/postage/batch.go#L18

Immutable   bool     // if the batch allows adding new capacity (dilution)

This suggests immutability controls whether a batch can be diluted (depth increased). However, looking at the actual code:

  • The increaseDepth function in the PostageStamp smart contract does not check the immutableFlag — dilution is allowed for both immutable and mutable batches.
  • The Immutable flag is actually checked in stampissuer.go in the increment() method, where it controls whether chunks can be overwritten when a bucket is full. Immutable batches return ErrBucketFull, while mutable batches reset the counter and allow overwriting.

The comment should reflect the actual behavior — immutability controls whether older chunks can be overwritten when buckets fill up, not whether the batch can be diluted.

Suggested fix:

Immutable   bool     // if true, chunks cannot be overwritten when buckets are full

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions