Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: blob/allocate response for already allocated or received blob #20

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

alanshaw
Copy link
Member

This PR fixes the response for a repeated blob/allocate for an existing blob.

Previously:

  • Not allocated and not received - allocated size: {blob size} and signed URL for put
  • Not allocated and received (allocated in another space) - allocated size: {blob size} and signed URL for put
  • Allocated but not received - allocated size: {blob size} and signed URL for put
  • Allocated and received - allocated size: 0, no URL

Now:

  • Not allocated and not received - allocated size: {blob size} and signed URL for put
  • Not allocated and received (allocated in another space) - allocated size: {blob size}, no URL
  • Allocated but not received - allocated size: 0 (already allocated in the space) and signed URL for put
  • Allocated and received - allocated size: 0, no URL

@alanshaw alanshaw requested a review from hannahhoward October 30, 2024 14:49
@alanshaw alanshaw force-pushed the fix/response-for-allocated-or-received-blob branch from 20c3f07 to 5c265c2 Compare October 30, 2024 14:53
Copy link
Member

@volmedo volmedo left a comment

Choose a reason for hiding this comment

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

LGTM!

Left a non-blocking comment and a couple questions that don't need to be answered now. Is this flow documented somewhere I could take a look to learn more?

pkg/service/storage/ucan.go Outdated Show resolved Hide resolved
Comment on lines +72 to +74
// the size reported in the receipt is the number of bytes allocated
// in the space - if a previous allocation already exists, this has
// already been done, so the allocation size is 0
Copy link
Member

Choose a reason for hiding this comment

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

q: does that imply that only the first space where a given blob was allocated is billed for that storage or this has nothing to do with charging users?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes originally this was for billing purposes. In the case of failed uploads the user may try to upload the same data again, or sometimes they just uplaod the same thing multiple times. However we don't want to change them multiple times so the size value accounts for this. We need to revisit what this means in a decentralized network, as this particular node does not have a view over the whole network and there is no guarantee a second allocation will come to the same node as before (would be useful though).

Copy link
Member

Choose a reason for hiding this comment

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

thanks for the context. I thought we were looking for previous allocations of the same blob in other spaces too, but I see now the check is scoped only to the space the invocation refers to.

about the issue in the decentralized scenario, would it be a possibility to store the DIDs of the spaces where a CID lives as part of the metadata when indexing? Storage nodes could then check with the indexing-service whether a given blob has already been allocated in that same space. I'm still missing a lot of context, so please let me know if that's just nonsensical 😄.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes sounds like a reasonable suggestion!

Copy link
Member Author

Choose a reason for hiding this comment

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

I've opened an issue with more details. #23 - would you mind adding your thoughts?

Comment on lines +108 to +109
// even if a previous allocation was made in this space, we create
// another for the new invocation.
Copy link
Member

Choose a reason for hiding this comment

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

q: this is for the case that a previous allocation invocation expired, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, exactly.

fmt.Println(*f.Stack)
require.Nil(t, f)
})
})
Copy link
Member

Choose a reason for hiding this comment

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

nit: it may be interesting to add a test for the missing case, the one where the blob has been received but is allocated in a different space, for the sake of completeness

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes good shout ab8c03c

@@ -17,7 +17,7 @@ import (

var log = logging.Logger("server")

// ListenAndServe creates a new indexing service HTTP server, and starts it up.
// ListenAndServe creates a new storage node HTTP server, and starts it up.
Copy link
Member

Choose a reason for hiding this comment

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

💯

@alanshaw alanshaw merged commit 185660b into main Nov 8, 2024
6 checks passed
@alanshaw alanshaw deleted the fix/response-for-allocated-or-received-blob branch November 8, 2024 11:41
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.

2 participants