Daohub-io / cap9

Capability-based security protocol for smart contracts
Apache License 2.0
22 stars 10 forks source link

Fix the quantity of gas used on syscalls #178

Closed JakeOShannessy closed 6 months ago

JakeOShannessy commented 5 years ago

As explained in #168, due the ordering of opcodes, passing the full remaining gas to a CALL is a little more complicated, we can't just call GAS and have the correct value on the stack, we must subtract the cost of the instruction in-between GAS and CALL.

This pull request attempts to subtract the exact amount. Because we are working directly with WASM here we can control that. I've noted in the comments a logical formulation for the subtraction required, although I don't believe that complies with any standard, this may just be a property of pwasm (which I don't believe claims to be fully compliant in that way).

I've noted in #168 that we can apply this technique elsewhere by linking in more lower-level custom WASM.

This is on top of cap9-core.

JakeOShannessy commented 5 years ago

Looks like I'm getting errors inconsistently on this. Let's leave it for now.