Skip to content

Syscall Cleanup #738

@Stebalien

Description

@Stebalien

We have a few inconsistencies in our syscall API that I'd like to address before M1:

Get/Resolve

  • actor::resolve_address
  • actor::get_actor_code_cid
  • actor::resolve_builtin_actor_type
  • actor::get_code_cid_for_type

Proposal: rename all to resolve_*.

NotFound errors

  • Most APIs will return a NotFound syscall error if the target resource isn't found.
  • The actor::* functions will return -1 if the actor isn't found, and actor::get_code_cid_for_type will return 0 if 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 (root and cid) 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:

  1. We just use 100 for the size everywhere.
  2. The length can be determined by parsing resulting CID.
  3. The fact that root and cid succeed 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:

  1. 4 multicodec-uvarints (max 9 bytes each) = 36
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions