Mechanism to ensure sufficient resources #646
Replies: 2 comments 3 replies
-
What is the threat model we are assuming here? Because if the C contract can be malicious, then C can just maliciously run out of memory or call stack. |
Beta Was this translation helpful? Give feedback.
-
Thanks for writing this up. Right now I'm not convinced either that we need it, or which way is better. I understand some of the hypothetical situations that give rise to this thinking, but none are concrete enough for me just yet. This could change if we realise that something like this is necessary to implement any version of, say, user-programmable markets, but I currently don't expect this to be the case. This is a great discussion to start, but to devote more energy I think we need more concrete use cases needing it, and an exploration how other smart contract environments have solved or avoided the stated problem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Currently, there's no way for some actor A to call some other actor B while ensuring that B has some minimum required resources (memory and stack depth).
For example, given actors A, B, and C:
At the moment, there's no (efficient) way for B to know if C is lying, or if A called B with very little call stack space remaining.
This becomes important when B needs to know if it should:
At the moment, a "safe" contract needs to assume (2).
Proposal
Add a flag to the "send" syscall to assert that there must be room for at least N (256?) recursive calls and at least M (256 or 512?) MiB of memory left.
Given our scenario above, this would allow B to call C while ensuring that it's giving C the minimum required resources
Alternatives
Send Flags versus Resource Usage Getters
An alternative to send flags is to provide some way to ask the system for the current memory used and/or current stack depth.
I'm proposing a flag because:
However, there are good reasons to just expose an
available_memory
syscall:available_memory
syscall isn't strictly-speaking necessary here.Really, I could be convinced either way.
Beta Was this translation helpful? Give feedback.
All reactions