-
Notifications
You must be signed in to change notification settings - Fork 147
Description
We have a few inconsistencies in our syscall API that I'd like to address before M1:
Get/Resolve
actor::resolve_addressactor::get_actor_code_cidactor::resolve_builtin_actor_typeactor::get_code_cid_for_type
Proposal: rename all to resolve_*.
NotFound errors
- Most APIs will return a
NotFoundsyscall error if the target resource isn't found. - The
actor::*functions will return -1 if the actor isn't found, andactor::get_code_cid_for_typewill return0if the actor is not a system actor.
Proposal: Use ErrorNumber::NotFound to indicate "not found" in all of these cases.
Motivation:
- Consistency with other APIs (ipld, send)
- Faster (we can remove redundant information)
- Less error prone.
- These are not "success" cases.
Context:
We use sentinel value in a few other cases:
- Signature, proof, etc. failed to validate.
- Consensus fault wasn't proven.
However, I would argue that these are different. In those cases, we want to distinguish between a failure (usually indicating that the caller did something wrong) and a successful "false".
Here, you're asking the system to do something (e.g., resolve an address) and the system is telling you "I couldn't do that (because the target actor doesn't exist, etc.)".
I feel like I'm splitting hairs a bit here, but I want to be consistent.
Take actor IDs where possible
Maybe?
Currently, get_actor_code_cid takes an address, not an ID.
CIDs Sizes
When returning a CID:
- The IPLD methods (
rootandcid) take a cid offset and a max length. They return the CID "size". - Everything else take takes a cid offset and a max length, returning nothing.
This is a bit sticky because:
- We just use 100 for the size everywhere.
- The length can be determined by parsing resulting CID.
- The fact that
rootandcidsucceed when they don't actually return a CID is suspect.
I did this because I wanted to support more general IPLD, but... I think I was being over general too soon.
Proposal(s):
Return a fixed 100 byte buffer. 100 bytes because:
- 4 multicodec-uvarints (max 9 bytes each) = 36
- 64 byte digest (max)
Is 100 bytes. It's also what we currently use.
Upside: simplicity.
Downside: CIDs are usually more like 38 bytes, so that's a massive over-allocation (and we have to "copy" a bunch of zeros at the end for determinism). BUT, well, we're doing that anyways (on the wasm side, at least). These will almost always be quick stack allocations, so we should be fine.