Bound parallel verification of transactions
Motivation
This PR bounds the memory usage during transactions verification by introducing MAX_PARALLEL_DEPLOY_VERIFICATIONS and MAX_PARALLEL_EXECUTE_VERIFICATIONS, where we verify a limited number of transactions at once instead of all at once. Previously the unbounded verification could lead to OOM errors when a node is forced to verify many large/expensive transactions at once.
Profiling memory usage of verification gives us some insights -
https://github.com/AleoHQ/snarkVM/pull/2376#discussion_r1509093306
Deployment: The maximum RAM to verify a 1M constraint program is 2GB. Execution: The maximum RAM for a 1 or 31-depth 1M constraint call execution is negligible, but to be safe we could assume 10MB.
For an upper bound of 10GB of memory dedicated to transaction verification, we set the following values to:
MAX_PARALLEL_DEPLOY_VERIFICATIONS: 5
MAX_PARALLEL_EXECUTE_VERIFICATIONS: 1000
This means we verify deployments first (in chunks of 5), then executions after (in chunks of 1000).
@vicsn Since the pre-speculate verification PR - https://github.com/AleoHQ/snarkVM/pull/2376 was merged, this PR had to be updated with the same change on the VM::speculate side.