casper-node
casper-node copied to clipboard
Optimize get_call_stack on host side
As it turns out, runtime::get_call_stack
is an essential function call for smart contract security purposes. But unfortunately, it is a costly one: it calls 2 host functions, deserializes the whole vector of CallStackElement, and the enum serialized is rather big.
There are at least two use cases of it:
- Returns the immediate caller. We can turn this into a host function that will return only one
CallStackElement.
- Returns the bottom of the call stack to (i.e. get_caller) ensure a session is a caller.
Find the cheapest way to query the call stack to achieve the results.