casper-node icon indicating copy to clipboard operation
casper-node copied to clipboard

Optimize get_call_stack on host side

Open mpapierski opened this issue 3 years ago • 3 comments

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.

mpapierski avatar Sep 01 '21 17:09 mpapierski