Replies: 3 comments
-
I was informed that host part is "free" of gas charging and only VM part should be counted (e.g. it can be the counter of executed instructions, or counter of clock cycles spent by program). If we would like to go into charging also for syscalls imo we should consider 2 options:
|
Beta Was this translation helpful? Give feedback.
-
Actually we already have one "paid" syscall - the ED25519 signature verification (it has a constant cost). If we want/need variable-cost syscalls, the cost would have to be predictable - how would the executors agree on the cost otherwise? I think the cost should be a function of the syscall arguments. The problem is that currently the syscall cost is hardcoded in the syscall number (it's inherited from SP1) and this would need to be changed. impl SyscallCode {
pub fn num_cycles(&self) -> u32 {
(*self as u32).to_le_bytes()[2].into()
} |
Beta Was this translation helpful? Give feedback.
-
💯 For reference we can study how this is done in EVM, for those opcodes that have a "dynamic" gas cost:
e.g.: |
Beta Was this translation helpful? Give feedback.
-
Right now, Athena does extremely simplistic gas metering: basically all instructions have a fixed gas cost of 4 (based on the word size in bytes). At the very least, we should attempt to properly meter host calls such as read/write storage, call, etc. Estimate how much these actually cost in terms of consumed resources (storage, bandwidth, compute), create a straightforward formula for each host call (e.g., based on the size of the call data), and implement more sophisticated, accurate gas pricing.
Beta Was this translation helpful? Give feedback.
All reactions