-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make some host errors non-recoverable in try_call
.
#945
Conversation
- Internal errors that indicate host implementation/setup bugs - a good chunk of it indicates severely broken host state and we probably don't want to continue execution if that happens. We also would want to learn about these ASAP - Running out of budget - while this would be handled 'automatically' during the normal execution, this makes test experience a bit more consistent (as compiled contracts are not metered) - Accessing entries outside of the footprint - this is probably the most controversial change, but there is really no indication/expectation that storage interface doesn't behave as a key-value database and hence it's pretty easy to write logic that relies on that fact without considering the existence of the footprint. `try_call` recovering from footprint errors is functionally equivalent to `get_contract_data` recovering from footprint errors (imagine a simple storage wrapper contract) and we really don't want allowing that.
Hmm. I'm a bit uneasy about this. A few separate comments:
I'm a bit on the fence about whether "a true wasmi bug should be recoverable or not". On the one hand it's probably adequately contained by us disposing of the VM (as we'll do in any case). On the other, it's plausible the VM did something to the host that the I think we should get input from more people before landing this. It implies subtle differences in the user's ability to write robust code, either way. cc @MonsieurNicolas, @tomerweller, @paulbellamy |
That's not true at the very least in tests and I'm also not 100% sure if doing something like
I think they are different. Accessing a value that is not in the footprint is not a contract programming error. It's an error of whoever has created the transaction. From the contract writer standpoint footprints do not exist and storage has map-like semantics. We don't intentionally expose the state where "the key is maybe in storage, but we don't really know because it's not in the footprint", we just panic. I think that's the correct design choice, but we do break it if
Nothing in the interface prevents users from e.g. using Another reason is that footprint is not only a concurrency tool, but also a paid resource (as it defines the ledger reads). I think it's safer to enforce it strictly in the same fashion as we strictly enforce every other resource. I don't have a good idea on whether this can be exploited, but I would err on the more conservative side here. I think sandboxing subcontract calls is something we may or may not want to do in vN, but as it's not happening in v1, I'm not sure we should sandbox one arbitrary resource and not the others (e.g. why then not allow to handle running out of memory etc.) |
FWIW I'm with Dima on this one: we can in a future protocol upgrade relax things, so starting with the more conservative stuff seems fine to me. On the specifics here:
|
This allows reserving internal errors for wasm-related logic errors on the host side.
I think ideally |
What
Make some host errors non-recoverable in
try_call
.Resolves #876
Why
try_call
recovering from footprint errors is functionally equivalent toget_contract_data
recovering from footprint errors (imagine a simple storage wrapper contract) and we really don't want allowing that.Known limitations
N/A