Skip to content

Misleading comment on Batch.Immutable field #5334

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

seenIssue has been reviewed as part of the weekly issue rotation.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions