For a given transaction, the Solana runtime consumes CUs for many “operations”. Examples of operations could be read/write locking accounts, syscalls, signature verification, etc. as seen in the cost model or compute budget. Imo it’s pretty clear how those factors contribute to CU consumption.
What is not clear is how the execution of BPF code (a.k.a the on-chain program itself) affects CU consumption. In the cost model the field I'm interested in is programs_execution_cost
. How is this cost calculated?
As far as I can tell, the EbpfVm executes an instruction while holding a reference to the invoke context and the VM simply consumes 1 CU per BPF instruction?. If I look at the BPF Loader, also 1 VM instruction seems to equal 1 CU?
Is it really that simple?