-
Notifications
You must be signed in to change notification settings - Fork 12
Further optimisation of valid jump destination computation #602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Actually, checking the preceding 32 bytes is not enough. You have to also check, if you do find a PUSH in that preceding 32 bytes, is that PUSH actually just part of the push data of a prior push? So there isn't a way to know except scanning from the start of the bytecode. |
Yes, that is correct. |
Other considerations from Slack:
In addition, there's a potential follow-up to a change in valid |
Currently, we are computing jump destinations AOT, with the help of
pyk
. This allows us to handle programs with symbolic parts (such as immutable variables), but is slightly slower than the original approach that was fully integrated with the semantics.We also have a PR open in KEVM that enables JIT computation, and which is much faster, but incomplete in that it does not account for cases when a jump is made into
PUSH
data, which should result in aEVMC_BAD_JUMP_DESTINATION
error. Extending that PR to account for these cases as well is likely to end up being slower, since what we would need to do is, given a check for a jump destinationI
:I
;PUSH-N
, such thatI
is included in theN
following bytes;I
.In general, the assumption that no
JUMP/JUMPI
lands inPUSH
data does not hold for arbitrary EVM code. However, it could be safe in the case of Kontrol, since we are working exclusively with EVM code coming from the compilation of Solidity files. Since the EVM execution never continues if such a jump occurs, I can't think of a use case for the compiler do be doing this deliberately. Perhaps we could ask the developers for their opinion.If we think that this assumption will be safe, we could implement a layer in Kontrol only that always sets the jump destinations to
.Set
and only does a basic JIT check. This should give us a solid speed-up.Alternatively, we could think of automatically generating K rules that capture valid jump destinations for each contract. These rules should be handled very efficiently by the LLVM backend.
The text was updated successfully, but these errors were encountered: