Skip to content

[Optimization] Inefficient fetching of credits.aleo PKs #2416

@raychu86

Description

@raychu86

It looks like our VM does not fetch the credits.aleo proving keys from the resources folder and simply resynthesizes them from scratch at time of use. This is completely safe, however will incur a one-time synthesis cost.

When we fetch the proving keys functions via Stack::get_proving_key, we check if the function is a credits.aleo function and read the proving key directly from the bytes in .resources if it is. This is done in Stack::execute - https://github.com/AleoHQ/snarkVM/blob/2cbf34a1010bf781277cdc6ff1ae966230cf97c1/synthesizer/process/src/stack/execute.rs#L462

However a few lines above, we are always re-synthesizing the key at first time of use: https://github.com/AleoHQ/snarkVM/blob/2cbf34a1010bf781277cdc6ff1ae966230cf97c1/synthesizer/process/src/stack/execute.rs#L425-L429 This ignores the optimization we have for the PKs where we can simply read from bytes instead of resynthesizing.

Note: The current behavior does NOT impact security, but can be optimized.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions