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

Debug self-encryption of small files #385

Closed
bochaco opened this issue Jun 25, 2024 · 7 comments
Closed

Debug self-encryption of small files #385

bochaco opened this issue Jun 25, 2024 · 7 comments
Assignees

Comments

@bochaco
Copy link
Contributor

bochaco commented Jun 25, 2024

Currently, trying to call self encryption on a small file leads to undesirable results.
We should just have 1 chunk + data map for a small file, instead we get 3 chunks. + data map.
It is from this function get_num_chunks inside self encryption.

Also, earlier we had a method to encrypt small files separately, but now it is removed, maybe that is the cause? Anyways, move that functionality into self-encryption crate.

Also add logging to self encryption.

@bochaco bochaco self-assigned this Jun 25, 2024
@bochaco
Copy link
Contributor Author

bochaco commented Jun 25, 2024

@RolandSherwin how exactly do you envision this to work, when you say small files what's the range of sizes you actually mean here? is it between 3 * MIN_CHUNK_SIZE and 3 * MAX_CHUNK_SIZE ? if so, for a file of size let's say 2 * MAX_CHUNK_SIZE we'll need to generate datamap + 2 chunks, right? and that'd be a different mechanism as SE needs at least three chunks to work...

@happybeing
Copy link

I don't know if this is a good place to raise this, but it would be nice to have an API for self encrypting a block of memory. Currently it only allows self encryption of a file on disk and its not good to force data to be written to disk just for this purpose.

@RolandSherwin
Copy link
Member

Hey @bochaco. Right, I see! Also, we were having troubles when actually trying to upload those extra chunks. We fetched store cost + paid + sent over chunk+payment, but they were never accepted.
I can try to reproduce it locally.

@happybeing
Copy link

happybeing commented Jun 26, 2024

I can try to reproduce it locally.

These may be two separate bugs.

Firstly uploading individual small files does work (ie safe files upload -p <FILE>).

But uploading a directory (ie safe files upload -p <DIRECTORY>) fails with payments never being enough, and wallet gets drained (logs posted on forum for Qi here).

@bochaco
Copy link
Contributor Author

bochaco commented Jun 26, 2024

After digging in, the issue with small files ending up in 1 chunk (plus the data-map chunk) is due to the fact that files that are smaller than 3 * MAX_CHUNK_SIZE are split into 3 chunks, thus if the content of the file is by chance something like "hello\nhello\nhello\n" it ends up being split into three equal chunks: "hello\n".
So that seems all ok to me, at least, as long as we are ok with dealing that way with small files as mentioned above.

@happybeing
Copy link

@bochaco That sounds like the issue riddim isolated as he was just adding the same text to a file to see what happened to the upload cost.

It doesn't explain the issue I was experiencing and reported to Qi Ma. Is anyone looking into that?

@bochaco bochaco removed their assignment Jun 26, 2024
@mickvandijke mickvandijke self-assigned this Aug 6, 2024
@mickvandijke
Copy link

Closing this because the behaviour is as intended.

@mickvandijke mickvandijke closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2024
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

No branches or pull requests

4 participants