titanoboa
titanoboa copied to clipboard
Gas profiler does not give a name to getter functions for public variables
When accessing a public variable and generating a gas profile, the profiler returns unnamed
instead of the getter function's name
Example: https://try.vyperlang.org/hub/user-redirect/lab/tree/Gas%20Profile%20Public%20Variable.ipynb
import boa
from boa.profiling import get_call_profile_table, get_line_profile_table
from boa.vm.gas_meters import ProfilingGasMeter
seeder = boa.env.generate_address()
trader = boa.env.generate_address()
coin_a = boa.load("ERC20.vy", "coinA", "cA", 18)
coin_a._mint_for_testing(seeder, 1000000000000000000000000)
with boa.env.gas_meter_class(ProfilingGasMeter):
with boa.env.prank(seeder):
coin_a.transfer(trader, 100000000000000000000)
coin_a.balanceOf(trader)
get_call_profile_table(boa.env)
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳┳┳┳┳┳┓
┃ Contract ┃ Address ┃ Computation ┃┃┃┃┃┃┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇╇╇╇╇╇┩
│ ERC20.vy │ 0x2cb6bCe32aeF4eD506382896e702DE7Ff109D9… │ transfer │││││││
│ │ │ unnamed │││││││
└───────────────────────────────┴───────────────────────────────────────────┴───────────────────────────────┴┴┴┴┴┴┘
I would expect to see balanceOf
in the profiler, but instead it's listed as unnamed
.
(I would also expect the gas stats to actually appear in the table, even though it may not be the orthodox usage of the feature).
the gas stats not appearing is a drawback of the table renderer, they just get lost if there is truncation. we should also export the gas results to csv or a prof file honestly.
btw, i think public variables not appearing is a bug in vyper's source map generation, which should have been fixed in 0.4.0 (https://github.com/vyperlang/vyper/commit/a91af13db9d6d89e6c2139c1b28c490845f06e13 if i'm not mistaken). can you try the beta and see if there are still issues?
@benber86 can we close this?