-
Notifications
You must be signed in to change notification settings - Fork 80
Support 1-byte jump label value #200
Comments
I don't think it's that trivial unfortunately, changing a |
What if we delegate it to the user? Like annotate if the label is 1 byte, something like |
@minaminao where did you read that? All PUSH operations cost 3 gas except for PUSH0 which costs 2.
costs the same at runtime as
The only thing that changes is the deployment cost because each non-zero byte in the calldata costs 16 gas and each zero-byte costs 3. So actually by converting
into
you are saving 3 gas for the deployment and zero gas from the runtime. |
@Mouradif |
Right now My assembly library |
@minaminao Got it thanks! I wasn't aware of that |
I am not familiar enough with the codebase of https://github.com/Mouradif/evm-bunnyhop-rs It's not very well tested but it seemed to work on the one contract I'm working on |
A jump label value is calculated using 2 bytes and the
PUSH2
opcode is used, but when the value can be reduced to 1 byte, it is more gas efficient to use thePUSH1
opcode. (200 gas per byte)huff-rs/huff_codegen/src/lib.rs
Line 374 in a4f820a
An alternative is to support thejumpdst
opcode.jumpdst
could still be obtained by labeling it.(When I was implementing https://github.com/minaminao/huff-eip1167, I wanted the jump using
PUSH1
)The text was updated successfully, but these errors were encountered: