Actor Entrypoint Bikeshed 🎨 #792
Replies: 2 comments 1 reply
-
I am confused by the "variant" terminology here. What concrete solution are these two different variants of? If I understood correctly, there are four different proposals here, which are independent from each other:
On (1), method numbers are a Filecoin specificity, and the reason we didn't originally add them to the actor ABI was to keep the actor contract Filecoin-independent. In the future, we'd like FVM to work beyond Filecoin, so adopting this Filecoin convention at the ABI level just doesn't seem right. Doing this would glorify the Filecoin convention as the FVM convention. Given that the argument seems to be merely an optimization one, I'd skip doing this. On (2), modelling lifecycle/structural behaviours as exported Wasm functions (aka. "entrypoints") has several advantages:
On (3), seems fine to me. My only hesitation is that the codec is an IPLD specific notion, but FVM is designed to be an IPLD machine, the choice seems to align with that invariant. On (4), this doesn't seem urgent nor indispensable, as SDKs are bridging the control flow semantics of the language anyway. As you mentioned, multi-return support wasn't great in Rust the last time we looked, and we don't know about other languages. We'd need to evaluate this more carefully. |
Beta Was this translation helpful? Give feedback.
-
A: more parameters to invoke I am unconcerned about how that might impact other users of FVM. This is the Filecoin protocol forum and Filecoin is the first and currently only production user of the FVM. B: sentinel, negative method numbers for special methods Using method numbers would raise the possibility of an actor dynamically supporting upgrade or message validation or future behaviour, e.g. depending on state. While this is not all that difference from dynamically succeeding or failing when invoked, it still muddies the answer to "is this actor upgradeable?", which might have, e.g. security implications for users. Errors & Exit Codes |
Beta Was this translation helpful? Give feedback.
-
I'd like to bikeshed a few issues with the current Wasm-actor entrypoint so we can settle some open design discussions before we start allowing user-deployed Wasm actors and lock the existing design in-place.
Relevant reading:
validate
function)upgrade
function)constructor
function)invoke
signature ref-fvm#1166Variant A
Proposal: Change the
invoke
Wasm actor entry point signature from:To:
Motivation
The current Wasm actor entrypoint has a few downsides.
First, it doesn't include the method number, requiring that the user pull it from the "message context". This is both inefficient (requires a system call) and odd (we're literally invoking this method, but we're not passing it to the invoked actor).
Second, it doesn't include enough information to actually parse the parameters, requiring the user to call both
block_stat(param_block_id)
to learn the block's codec and size, thenblock_read(...)
to read the block into memory.Analysis
Variant B
In addition to "variant A" proposed above, reserve negative method numbers for "system" entrypoints:
-1
-- constructor (changed from its current value of 1)-2
-- upgrade (future upgrade)-3
-- validate (future account abstraction)And use these instead of introducing new Wasm entrypoint functions.
Affects: #500, #396, #388
Motivation
At the moment, there's no reserved set of "special" method numbers that can only be invoked by the FVM, sort of.
We have a few cases where we want actors to be able to "opt-in" to some behavior where blindly returning "ok" could be dangerous. For example, account abstraction needs some way to ask the account if a message is a valid message from the actor in question. Blindly responding with "ok" here would mean anyone would be able to send messages on behalf of this actor.
In that case, the alternative we proposed was to introduce a new
validate
wasm-level entrypoint. That way, actors have to "opt-in" to being abstract accounts. Unfortunately, this has a few issues:So here I'm proposing that we do continue to use method numbers for these "methods", just out of a special reserved range (where actors would, by default, reject all calls on unhandled negative method numbers).
Alternatives & Extensions
Errors & Exit Codes
One remaining issue with the
invoke
entrypoint is the fact that it can't return an error. The only wait of fail with an error is to call thevm::exit
syscall with an exit code.Ideally
invoke
would return a tuple:(return_block_id, error_code)
. Unfortunately, working with multiple return values in rust+wasm is non-trivial, although doable if there's a consensus that this is the "right" approach. I assume it'll become less painful in the future, for what it's worth.An alternative would be to say that negative return values indicate exit codes, non-negative return values are block IDs (where
0
means "success with value", as it does today). The downside of this approach is that it doesn't allow returning a value on failure, in addition to the error code.Length & Codec
We don't have to include the length/codec in the
invoke
signature and this isn't a hill I plan on dying on. It just removes a pointless syscall.Beta Was this translation helpful? Give feedback.
All reactions