Response Schemas#
Operations that return data via file descriptor use specific encoding formats based on operation type.
Sub-VM Result Encoding#
Operations that spawn sub-VMs (CallContract Message, RunNondet Message, Sandbox Message) return results through a file descriptor with the following binary format:
[result_code: u8][data: bytes]
Where result_code is a result_code:
return (
0): Successful executionuser_error (
1): Contract-initiated errorvm_error (
2): VM-level error
The data portion depends on the result code:
return: Calldata Encoded return value
user_error: Calldata Encoded error value
vm_error: UTF-8 encoded vm_error string
Validity Of A Proposed Result#
A result the executor did not compute itself — the leader-proposed non-deterministic result consumed in Sync Mode and Validator Mode — is accepted only if it satisfies all of the following. A rejected proposal is replaced by a derived VMError. Sync mode returns that replacement without a vote; validator mode records a disagreement without running the comparison stage
The buffer is non-empty. An absent or empty proposal yields leader_fault nondet_output absent.
result_codeis one of return, user_error or vm_error; any other byte yields leader_fault nondet_output malformed.For return and user_error,
datais valid Calldata Encoding with no trailing bytes; otherwise leader_fault nondet_output malformed.For vm_error,
datais UTF-8, carries no" # "detail, and names a vm_error path, including the canonical spelling of any parameter. Codes outside the trie yield leader_fault nondet_output malformed.A proposed timeout yields leader_fault nondet_output malformed.
An accepted result that passes Nondeterministic Output Caps is preserved byte for byte, so every node hashes the value that was proposed.
Derived-Outcome Namespace#
Following VMError codes are derived by the consuming executor rather than proposed:
A proposed code that equals, or extends at a space boundary,
leader_fault nondet_output is replaced by
leader_fault nondet_output uses_this_error
whose parameter is the first 6 characters of the
GVM32 (Base32) encoding of sha3_256 of the
proposed code. A proposal that is its own replacement maps to the parameter
fix_point, which cannot collide with a derived parameter because it is 9
characters long and a derived one is always 6.
This check runs before the trie-validity check, so proposing a derived code verbatim can never produce output byte-equal to the proposal. Distinct proposals may share a parameter; the mapping is deterministic and the value carries no meaning beyond identifying the proposal as rejected.
Module Result Encoding#
Operations that invoke external modules (WebRender, WebRequest, ExecPrompt,
ExecPromptTemplate) return results as Calldata Encoded
data with a success/error wrapper:
// On success
{
"ok": <result>
}
// On error
{
"error": <error_details>
}
The <result> structure depends on the operation:
WebRender Response#
Returns one of the following based on render mode:
// For mode "text"
{"ok": {"text": String}}
// For mode "html" (returns HTTP response)
{"ok": {"response": Response}}
// For mode "screenshot"
{"ok": {"image": Bytes}}
Where Response is:
{
"status": Number, // HTTP status code (u16)
"headers": Map, // String -> Bytes mapping
"body": Bytes // Response body
}
WebRequest Response#
{
"ok": {
"status": Number, // HTTP status code (u16)
"headers": Map, // String -> Bytes mapping of response headers
"body": Bytes // Response body
}
}
ExecPrompt Response#
// When response_format is "text"
{"ok": String}
// When response_format is "json"
{"ok": Object}
ExecPromptTemplate Response#
// For EqComparative template (boolean result)
{"ok": Bool}
// For EqNonComparativeValidator template (boolean result)
{"ok": Bool}
// For EqNonComparativeLeader template (text result)
{"ok": String}
Module Error Format#
When a module operation fails, the error is returned as:
{
"error": <GenericValue>
}
Where <GenericValue> may contain error details from the module.