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

Perserve ordering across public and private calls in accounts entrypoint #1645

Closed
spalladino opened this issue Aug 18, 2023 · 2 comments · Fixed by #2348
Closed

Perserve ordering across public and private calls in accounts entrypoint #1645

spalladino opened this issue Aug 18, 2023 · 2 comments · Fixed by #2348
Assignees
Labels
T-bug Type: Bug. Something is broken.

Comments

@spalladino
Copy link
Collaborator

spalladino commented Aug 18, 2023

When a user enqueues a batch of calls in their account contract, all private functions get processed first, and all public functions get enqueued afterwards. But this can be a problem if one of the private functions enqueues a public call, since it breaks the expected ordering. For instance, if the user creates a batch with:

  1. Enqueue call to public function A
  2. Call private function privB (which enqueues a call to public function B)

It'd be expected that A gets processed before B. However, since privB is processed first by the account contract, then B is enqueued before A. This can be confusing to the user. I know first-hand because I just lost over an hour trying to debug an issue #1639 caused by this. And to make it more humilliating it was me who wrote the code account contract entrypoint. Oh well.

Self-rant aside, we should tweak the entrypoint so, instead of receiving two arrays of FunctionCalls (one for private, one for public), it receives a single array of FunctionCalls with a flag indicating whether each is private or public. This requires modifying the entrypoint_payload.ts and entrypoint.nr files. We should also update accordingly the pseudocode for the account contract in the Accounts guide in the docs.

@github-project-automation github-project-automation bot moved this to Todo in A3 Aug 18, 2023
@spalladino spalladino added the T-bug Type: Bug. Something is broken. label Aug 18, 2023
@iAmMichaelConnor
Copy link
Contributor

Thanks for this clear write up.

An attempt to summarise the issue in my own words, to make sure I've grasped it:
Currently, the entrypoint interface doesn't give a user enough freedom to express the ordering of their transaction request. This can lead to public functions being enqueued in the wrong order.
This is an independent problem from us trying to fix the ordering of public function calls which are enqueued by private functions?

How did I do?

@spalladino
Copy link
Collaborator Author

You nailed it, as always :-)

And yes, it's an independent issue. It was uncovered when trying to fix it though.

@spalladino spalladino self-assigned this Sep 15, 2023
@spalladino spalladino moved this from Todo to In Review in A3 Sep 15, 2023
spalladino added a commit that referenced this issue Sep 18, 2023
)

Fixes #1645 

This issue became more pressing since the introduction of
`is_valid_public` in accounts, since a user now should first invoke
`set_is_valid_storage` (a public function call) as many times as needed
to set up authorisations needed for public executions, and _then_ have
these public functions run. Otherwise, these runs will fail to find the
`is_valid` flags in storage.
@github-project-automation github-project-automation bot moved this from In Review to Done in A3 Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: Bug. Something is broken.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants