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
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions src/api/archive_unstable_call.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ The JSON-RPC server must invoke the entry point of the runtime of the given bloc

**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.
- `{ "success": false, "error": ... }` is returned if a problem happens during the call, such as a Wasm trap, runtime panics, function not supported etc. The `error` isn't meant to be shown to end users, but is for developers to understand the problem.
10 changes: 5 additions & 5 deletions src/api/sudo_sessionKeys_unstable_generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

**Return value**:

- If the runtime supports the function call (see below), an object of the form `{"result":"..."}` where `result` contains a string containing the hexadecimal-encoded output of the runtime function call.
- Otherwise, an object of the form `{"error":"..."}` where `error` is a human-readable error message indicating the problem. This string isn't meant to be shown to end users, but is for developers to understand the problem.
- If the runtime supports the function call (see below), an object of the form `{ "success": true, "value": ... }` where `value` contains a string containing the hexadecimal-encoded output of the runtime function call.
- Otherwise, an object of the form `{ "success": false, "error": ... }` where `error` is a human-readable error message indicating the problem. This string isn't meant to be shown to end users, but is for developers to understand the problem.

The JSON-RPC server must check that the runtime supports the `SessionKeys` API (64bits blake2 hash: `0xab3c0572291feb8b`) at version 1, and call the `SessionKeys_generate_session_keys` runtime function.
The runtime call is done against the current best block of the chain.
Expand All @@ -20,9 +20,9 @@ Contrary to most other JSON-RPC functions that perform runtime function calls wh

## Possible errors

- `{"error":"..."}` is returned if the runtime doesn't support the given API.
- `{"error":"..."}` is returned if a problem happens during the call, such as a Wasm trap.
- `{"error":"..."}` is returned if the runtime attempts to modify the storage of the block.
- `{ "success": false, "error": ... }` is returned if the runtime doesn't support the given API.
- `{ "success": false, "error": ... }` is returned if a problem happens during the call, such as a Wasm trap.
- `{ "success": false, "error": ... }` is returned if the runtime attempts to modify the storage of the block.

## About the behavior of `SessionKeys_generate_session_keys`

Expand Down