Closed shenghaoyuan closed 1 month ago
The first question can be omitted as due_insn_count +1
is in a throw_error branch.
The second is so that it is interface compatible with JIT compiled programs upon entry in a syscall. The syscall helper wrapper in program.rs does expect the CU metering to have been flushed.
Hello, I have two questions about CUs computation of the Solana interpreter, could someone please give me some suggestions?
self.vm.due_insn_count += 1;
, why?self.vm.due_insn_count = self.vm.previous_instruction_meter - self.vm.due_insn_count;
and after invoking function, doesself.vm.due_insn_count = 0;
, why? Could we remove those two lines from the interpreter (and also modify the program.rs )?https://github.com/solana-labs/rbpf/blob/main/src/program.rs#L331 vm.context_object_pointer.consume(vm.previous_instruction_meter - vm.due_insn_count); //
vm.previous_instruction_meter - vm.due_insn_count
->vm.due_insn_count
... vm.previous_instruction_meter = vm.context_object_pointer.get_remaining(); // removing