snarkVM icon indicating copy to clipboard operation
snarkVM copied to clipboard

[Perf] Speed up authorize by evaluating instead of executing

Open vicsn opened this issue 7 months ago • 2 comments

Motivation

This PR speeds up authorize significantly. This is done by letting authorize call evaluate_function instead of execute_function, while ensuring these functions have the same interface. Evaluation doesn't generate a circuit under the hood.

This does come at the cost of reduced UX: the user doesn't get feedback on whether they're creating a satisfying circuit. Note that there's no safety issue here; an authorization for an unsatisfied circuit will just lead to failing proof generation and verification. Moreover, for executions of common programs on common input, e.g. credits.aleo/transfer_public, the circuit is unlikely to be unsatisfied.

I added an authorize_checked function for clients/users who want to run this early extensive check anyway.

Testing

Existing unit tests should suffice, they use both the old and new version.

vicsn avatar Jun 11 '25 23:06 vicsn

On the API: do we want an authorize_unchecked instead of making it the default in authorize? This would also avoid the breaking change to callers.

niklaslong avatar Jun 18 '25 11:06 niklaslong

On the API: do we want an authorize_unchecked instead of making it the default in authorize? This would also avoid the breaking change to callers.

It's a good question which of the two versions should be the default. Either way, this PR doesn't touch any public API, its all internal. My opinion is that its fine to have the fast version be the default. I added more commentary in the PR description above.

vicsn avatar Jun 20 '25 18:06 vicsn

Can you quantify the need for this change in terms of runtime difference? What are the major unlocks? Browser authorization generation?

I am always nervous when touching Stack operations, however the logic looks fairly straightforward.

raychu86 avatar Jul 10 '25 00:07 raychu86