Open obatirou opened 1 year ago
Isn't this already possible with __codesize(MAIN)
and __codesize(CONSTRUCTOR)
? Would be cool to have a built-in for the sum of the two tho i.e. deploy code, which would be very useful for determining the position of constructor arguments.
Also, a builtin to get the code offset for certain constants/placeholders would help immensely, have had to write a script to find that manually in METH: https://github.com/Philogy/meth-weth/blob/main/script/build-helpers/immutable-offsets.py
Isn't this already possible with
__codesize(MAIN)
and__codesize(CONSTRUCTOR)
? Would be cool to have a built-in for the sum of the two tho i.e. deploy code, which would be very useful for determining the position of constructor arguments.Also, a builtin to get the code offset for certain constants/placeholders would help immensely, have had to write a script to find that manually in METH: https://github.com/Philogy/meth-weth/blob/main/script/build-helpers/immutable-offsets.py
__codesize(MAIN)
+ __codesize(CONSTRUCTOR)
will work for contracts that do not have a jumptable
: they are appended at end of the MAIN
bytecode but are not considered part of the MAIN
macro leading to differences between __codesize(MAIN)
and deploy code.
I agree with you, would be nice to have a built-in for deploy code size.
Interesting idea for the code offset of placeholders !
Oh I see, yeah that'd be helpful. Not to mention __codesize(MAIN) __codesize(CONSTRUCTOR) add
costs 9 gas and is 7-bytes vs if it was a single push instruction (3-bytes and 3 gas).
A builtin to get the runtime code could make sense, especially with contracts having jumptable / immutable variables. Creation code could also have use cases.
cc @Philogy First suggested by @Maddiaa0