Daohub-io/cap9

Procedure Execution with StaticCall

Closed this issue · 2 comments

Background

When executing a procedure we need to make sure:

  1. Unprivileged State Access/Modifications are rejected.
  2. State Access using a valid capability is accepted.

Proposal

  1. When executing a procedure from the kernel we use STATICCALL instead of DELEGATECALL.
    When executing a procedure from kernel space:
  2. To prevent state changes instead of checking for opcodes, we rely on STATICCALL to prevent them at runtime.
  3. Whenever a procedure requires a kernel resource, it returns the current memory with a 64 byte header which includes: The capability invoked, argument location, input location, and next valid jump location within the procedure stack.
  4. If a kernel receives a valid invocation, it dispatches the requested resource, if the resource returns any data, the data is included into the input location. The procedure then reads the next jump location, and continues execution.

Considerations

As an example, when accessing SSTORE, this proposal incurs the additional cost of aSTATICCALL, it remains to be seen if it is cheaper to simply encapsulate an opcode than to do context switching.

I'm trying to work around a problem with point 2 of the proposal section. All solutions for system calls seem to rely on variable length return values. The problem is these values could be extremely variable, but must be set before the contract is called. If we want to return all the memory from a child contract how big could that be? It could be very large or not much at all. We have to allocate space for the largest quantity possible. We obviously can't do this with the maximum possible amount of 2^256, so it would mean setting a memory constraint, then setting aside that amount in the kernel whenever we call a contract. It would also need to account for nested calls.

@JakeOShannessy: I believe we can put this on hold since we have decided on going with delegate re-entrancy.