EVM/Kernel: prevent circular calls of impure precompiles
What
This MR introduces mechanisms that prevent circular kernel calls, like:
- FA withdrawal -> ... -> XTZ withdrawal precompile
- FA withdrawal -> ... -> FA withdrawal precompile -> ... -> FA withdrawal precompile -> ...
Why
Although circular calls / reentrancy do not immediately introduce issues, there can be some implications we've not discovered yet.
Potential problems:
- Amplified spam attack
- Outbox censorship attack
- Double spending attack (tez/tickets)
How
A special reentrancy guard is introduced to the EVM handler, it tracks the call stack and identifies circular precompile calls (specifically XTZ/FA withdrawal precompile)
Manually testing the MR
make test
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Michael Zaikin