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

feat: add fallback option if no t_aux file exists #1715

Closed
wants to merge 1 commit into from
Closed

Conversation

vmx
Copy link
Contributor

@vmx vmx commented Sep 1, 2023

The only information from the t_aux file that is used during Commitphase 1 (C1) is the number of rows that are discarded from TreeC. If that value is either the default, or set via FIL_PROOFS_ROWS_TO_DISCARD accordingly, then all other parts of t_aux can be inferred from the function call.

When FIL_PROOFS_T_AUX_IMPLICIT_FALLBACK=1 is set, then those inferred values will be used, in case the t_aux file cannot be read or doesn't exist.

path: cache_path.clone(),
id: CacheKey::CommRLastTree.to_string(),
size: Some(tree_size),
// A default 'rows_to_discard' value will be chosen for tree_r_last, unless the user
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's possible that this part/assumption may break things. It's reasonable, but may require some more thought/testing across those cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would it break things? This is copy and pasted from the original code. The only difference is that we take the default value/the env variable and don't read it from disk.

Is this a comment or blocking a merge? If it's blocking, what do you suggest?

// Switch t_aux to the passed in cache_path
res.set_cache_path(cache_path);
res
match fs::read(&t_aux_path) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As-is, this won't work for Sector Updates (and maybe other parts?). I don't think that path will be much more complicated, but does require more testing, as t_aux is very much not optional in at least that part of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't the Sector Updates part self-contained at https://github.com/filecoin-project/rust-fil-proofs/blob/2ec0a0fe4005a6f2f6659bbbc167a1d41ee855e0/filecoin-proofs/src/api/update.rs? This part should only concern the C1.

So would be adding a test that removes the t_aux and then runs C1 be sufficient?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The sector updates code currently relies on t_aux being available and if it's not available from an earlier step in sealing, future sector updates won't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, now I get it. The problem is not about the code paths. Each works fine independently. The problem is that if someone seals a CC sector and removes their t_aux, they could then still C1, but they later could not do a sector update.

This means that I also need to take care of the sector update code path. Would adding a similar fallback there be an OK solution?

@vmx
Copy link
Contributor Author

vmx commented Sep 4, 2023

I thought about this again. Would it help that we make it clear in the README that you're on your own if you set the FIL_PROOFS_T_AUX_IMPLICIT_FALLBACK env variable? When you use the code in the current stack and there is a t_aux, nothing changes, it will also error if there is none.

If you don't have a t_aux and set FIL_PROOFS_T_AUX_IMPLICIT_FALLBACK, then it uses the default value, which is either the hard-coded one, or the one you can set dynamically via FIL_PROOFS_ROWS_TO_DISCARD. So even in case someone has set FIL_PROOFS_ROWS_TO_DISCARD to a custom value, I'd expect it to be set all the time. This means that even if then t_aux would be deleted FIL_PROOFS_T_AUX_IMPLICIT_FALLBACK would be set, it would still return the correct result.

The only information from the `t_aux` file that is used during Commitphase 1
(C1) is the number of rows that are discarded from TreeC. If that value is
either the default, or set via `FIL_PROOFS_ROWS_TO_DISCARD` accordingly, then
all other parts of `t_aux` can be inferred from the function call.

When `FIL_PROOFS_T_AUX_IMPLICIT_FALLBACK=1` is set, then those inferred values
will be used, in case the `t_aux` file cannot be read or doesn't exist.
@vmx vmx changed the base branch from synthetic-porep to master September 13, 2023 13:48
@vmx
Copy link
Contributor Author

vmx commented Sep 14, 2023

Superseded by #1717.

@vmx vmx closed this Sep 14, 2023
@vmx vmx deleted the t_aux-fallback branch December 4, 2023 10:59
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