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

FPI: foreign account data loader #896

Merged
merged 26 commits into from
Oct 15, 2024
Merged

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Sep 24, 2024

WiP

TODO:

  • Update docs
  • Update changelog
  • Implement tests

Comment on lines 934 to 939
####
# This two chunks of code bellow are essentially doing the same thing, the problem why I
# can't create a dedicated procedure for them is that they're using different memory
# procedures. I can create two new procedures in memory and move the corresponding code
# there, although I'm not sure which approach will be better.
####
Copy link
Contributor

@bobbinth bobbinth Sep 25, 2024

Choose a reason for hiding this comment

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

I don't mind these being separate - but a coupe of comments:

  • I would probably create two separate procedures - e.g., something like load_account_storage_data and load_account_procedure_data.
  • This code is probably very similar to what we do in the prologue for the native account. Is there a way to use these procedures in both places?
  • Why do we use exec.mem::pipe_words_to_memory rather than exec.mem::pipe_double_words_to_memory here? As far as I know, both storage slots and procedures are take up 2 words.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the best option will be to move the validate_account_procedures and validate_account_storage_slots procedures from the prologue to the memory and use them in both places: in prologue and in api. That will solve the highlighted problems.

@Fumuran
Copy link
Contributor Author

Fumuran commented Sep 30, 2024

For some reason api.rs file in the tx-prover keeps generating with strange formatting, on which rustfmt is complaining.

@Fumuran Fumuran marked this pull request as ready for review September 30, 2024 20:30
@PhilippGackstatter
Copy link
Contributor

For some reason api.rs file in the tx-prover keeps generating with strange formatting, on which rustfmt is complaining.

prost-build does its own formatting with prettyplease by default and the format feature is enabled by default, too. So since that code is already formatted plus generated code tends not to be looked at very much it seems fine to just skip the formatting from rustfmt for the generated module. You could just add this in bin/tx-prover/src/server/mod.rs:

#[rustfmt::skip]
pub mod generated;

@Fumuran
Copy link
Contributor Author

Fumuran commented Oct 1, 2024

So since that code is already formatted plus generated code tends not to be looked at very much it seems fine to just skip the formatting from rustfmt for the generated module. You could just add this in bin/tx-prover/src/server/mod.rs:

I was thinking about it, It was just strange to me that current version of this module in next branch has a different formatting, which is accepted by the CI formatting checker. Somehow Santiago managed to make the proper formatting, so I should be able to do so too.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Looks good! Not a full review, but I left some comments inline.

@Fumuran Fumuran requested a review from bobbinth October 7, 2024 19:38
@Fumuran
Copy link
Contributor Author

Fumuran commented Oct 8, 2024

Well, it turned out that implementation of the foreign account verification took only a few more lines, so I included it in this PR.

@PhilippGackstatter
Copy link
Contributor

I was thinking about it, It was just strange to me that current version of this module in next branch has a different formatting, which is accepted by the CI formatting checker. Somehow Santiago managed to make the proper formatting, so I should be able to do so too.

If you force a rebuild of that file on next it also does not conform to what rustfmt expects. So I think the proper formatting on next is just the result of make format. Actually, the tx_kernel_errors.rs has the same issue now and it keeps regenerating on next and shows up as a changed file in git status, which is a bit annoying. I think we should probably add a rustfmt::skip to both of these modules. Wdyt 🙂 ?

@bobbinth
Copy link
Contributor

bobbinth commented Oct 9, 2024

I think we should probably add a rustfmt::skip to both of these modules.

Yeah - for auto-generated files I think we should skip the formatting so that they don't change as rustfmt rules get updated.

@Fumuran Fumuran force-pushed the andrew-fpi-foreign-account-loader branch from 828b32c to 9f29675 Compare October 9, 2024 13:14
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left some more comments inline - most of them are very minor.

Comment on lines +795 to +797
#! Advice map: {
#! CODE_COMMITMENT: [num_procs, [ACCOUNT_PROCEDURE_DATA]],
#! }
Copy link
Contributor

Choose a reason for hiding this comment

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

After this PR is merged, let's make a small follow-up PR to make this consistent with the storage loader (e.g., not pass num_procs via the advice map).

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that this PR is merged, @Fumuran, could you make a small PR to address the above comment?

Also, should we close the original FPI issue and create a new one which describes what changes need to be made after handling of dynamic procedure invocation is fixed in miden-vm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, sure.

Yes, I think it will be better. I'll create an issue for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created the #922 issue.

This was referenced Oct 12, 2024
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left one optional nit inline.

@bobbinth bobbinth merged commit 31154ee into next Oct 15, 2024
8 checks passed
@bobbinth bobbinth deleted the andrew-fpi-foreign-account-loader branch October 15, 2024 08:53
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