Skip to content
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

archive/call: Synchronize the return type with sudo/sessionsKeys #104

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/api/archive_unstable_call.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@

**Return value**:

- If no block with that `hash` exists, `null`.
- If the call was successful, `{ "success": true, "value": ... }` where the `value` is a string containing the hexadecimal-encoded SCALE-encoded value returned by the runtime.
- If the call wasn't successful, `{ "success": false, "error": ... }` where the `error` is a human-readable message indicating the problem.
- If no block with that `hash` exists, returns `null`.
- If the call was successful, `{"result": ... }` where the `result` is a string containing the hexadecimal-encoded SCALE-encoded value returned by the runtime.
- If the call wasn't successful, `{"error": ... }` where the `error` is a human-readable message indicating the problem.

The JSON-RPC server must invoke the entry point of the runtime of the given block using the storage of the given block.

**Note**: The runtime is still allowed to call host functions with side effects, however these side effects must be discarded. For example, a runtime function call can try to modify the storage of the chain, but this modification must not be actually applied. The only motivation for performing a call is to obtain the return value.

In situations where the provided runtime function doesn't exist, or the runtime crashes, or similar, an error is returned. The `error` isn't meant to be shown to end users, but is for developers to understand the problem.
If the height of the block hash provided is less than or equal to the current finalized block height (which can be obtained via `archive_unstable_finalizedHeight`), then calling this method multiple times is guaranteed to always return non-null and always the same result (except for the `error` message which is allowed to change).

If the block was previously returned by `archive_unstable_hashByHeight` at a height inferior or equal to the current finalized block height (as indicated by `archive_unstable_finalizedHeight`), then calling this method multiple times is guaranteed to always return non-null and always the same result (except for the `error` message which is allowed to change).
If the height of the block hash provided is greater than the current finalized block height, then the block might be pruned at any time and calling this method may return null.

If the block was previously returned by `archive_unstable_hashByHeight` at a height strictly superior to the current finalized block height (as indicated by `archive_unstable_finalizedHeight`), then the block might "disappear" and calling this function might return `null` at any point.
## Possible errors

- A JSON-RPC error if the provided parameters are invalid.
- `{"error":"..."}` is returned if a problem happens during the call, such as a Wasm trap, runtime panics, function not supported etc.