Skip to content

fix: do not allocate if blob is already stored#678

Merged
alanshaw merged 7 commits intomainfrom
ash/fix/do-not-allocate-if-already-stored
Mar 4, 2026
Merged

fix: do not allocate if blob is already stored#678
alanshaw merged 7 commits intomainfrom
ash/fix/do-not-allocate-if-already-stored

Conversation

@alanshaw
Copy link
Copy Markdown
Member

@alanshaw alanshaw commented Feb 23, 2026

If the blob is already successfully stored in the space, do not allocate again on a (potentially) new node.

The subtle change here is that when attempting to store a blob that has already been stored you receive the original allocation from the successful upload.

It means that there may be an address (URL to PUT to) in the allocation receipt. If there is, you ALSO need to check for a http/put receipt - because if it exists, then the blob was uploaded previously and you do not need to upload it again.

@alanshaw alanshaw requested a review from travis as a code owner February 23, 2026 17:16
result: { error: /** @type {{}} */ (new Error()) },
})
: await generateAcceptReceipt(blobPutTask.cid.toString())
const blobConcludePut = await createConcludeInvocation(
Copy link
Copy Markdown
Member Author

@alanshaw alanshaw Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just copy pasta error and wrong. If hasHttpPutReceipt was false then we'd get an errored receipt anyway and if it was true it would add a blob accept receipt 🤦‍♂️

@alanshaw alanshaw requested a review from a team February 24, 2026 15:26
@Peeja
Copy link
Copy Markdown
Member

Peeja commented Feb 26, 2026

Couldn't we just behave the same way as if we happened to pick a node where it was already uploaded? In fact, we could specifically "allocate" on a node where it's already been uploaded, and everything should flow from there, no?

Comment on lines +115 to +120
console.error(
'fetching %s receipt for task: %s: %o',
t.capabilities[0].can,
t.cid,
rcptRes.error
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug trace?

@alanshaw
Copy link
Copy Markdown
Member Author

alanshaw commented Mar 4, 2026

Couldn't we just behave the same way as if we happened to pick a node where it was already uploaded? In fact, we could specifically "allocate" on a node where it's already been uploaded, and everything should flow from there, no?

You could, it assumes the original upload node still exists or the handler has access to the current location(s) of the blob in the case that it does not. i.e. not just the fact that the blob is registered in the space.

I know we don't have provision yet for repair when failures happen or when nodes leave the network but when we do it feels simplier to keep the scope of what the upload flow needs to know small and hence the current location of a blob as a separate concern. What I mean is that when we do implement repair, I'd like to not touch the upload flow. If the upload flow needs to know the current location so that it can issue an allocation on the same node then we'll need to change the upload flow to consider that, or we'll likely just forget and find a bug later.

To summarise, I'd like to keep the process of onboarding a blob and managing it's current location separate if possible. Allocating again on the same node couples these processes.

@Peeja
Copy link
Copy Markdown
Member

Peeja commented Mar 4, 2026

I like that. I wasn't considering that Piri will also (I think) return no out.ok.address if it's already storing the blob for another space. That's an optimization that avoids some data transfer while adding the blob to the node, but the bytes are still "allocated" for the space (even if that's purely bookkeeping and not reflected in actual additional disk space). This change will become the way that the network makes adding a blob to a space idempotent, by avoiding even notionally allocating room on a node for a blob. That's essentially equivalent to what you're saying, right?

@alanshaw alanshaw merged commit 16a3be3 into main Mar 4, 2026
1 check passed
@alanshaw alanshaw deleted the ash/fix/do-not-allocate-if-already-stored branch March 4, 2026 18:03
alanshaw pushed a commit that referenced this pull request Mar 4, 2026
…9.100, @storacha/ui-core@2.4.163, @storacha/upload-client@1.4.1, @storacha/client@2.1.1, @storacha/upload-api@3.2.1, @storacha/cli@2.1.1 (#684)

## @storacha/encrypt-upload-client@1.1.80 (2026-03-04)

### 🧱 Updated Dependencies

- Updated @storacha/upload-client to 1.4.1
- Updated @storacha/client to 2.1.1

## @storacha/ui-react@2.9.100 (2026-03-04)

### 🧱 Updated Dependencies

- Updated @storacha/encrypt-upload-client to 1.1.80
- Updated @storacha/ui-core to 2.4.163

## @storacha/ui-core@2.4.163 (2026-03-04)

### 🧱 Updated Dependencies

- Updated @storacha/client to 2.1.1

## @storacha/upload-client@1.4.1 (2026-03-04)

### 🩹 Fixes

- fix: do not allocate if blob is already stored
([#678](#678))

### ❤️ Thank You

- ash

## @storacha/client@2.1.1 (2026-03-04)

### 🧱 Updated Dependencies

- Updated @storacha/upload-client to 1.4.1
- Updated @storacha/upload-api to 3.2.1

## @storacha/upload-api@3.2.1 (2026-03-04)

### 🩹 Fixes

- fix: do not allocate if blob is already stored
([#678](#678))

### ❤️ Thank You

- ash

## @storacha/cli@2.1.1 (2026-03-04)

### 🧱 Updated Dependencies

- Updated @storacha/client to 2.1.1
- Updated @storacha/upload-api to 3.2.1

Co-authored-by: Rachabot <rachabot@storacha.network>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants