Skip to content

Commit 12dd1a7

Browse files
authored
Stabilize archive methods (#167)
1 parent c5453d1 commit 12dd1a7

19 files changed

+60
-59
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
book
2+
.DS_Store

src/SUMMARY.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
- [Load balancers](load-balancers.md)
99
- [API specification](api.md)
1010
- [archive](api/archive.md)
11-
- [archive_unstable_body](api/archive_unstable_body.md)
12-
- [archive_unstable_call](api/archive_unstable_call.md)
13-
- [archive_unstable_finalizedHeight](api/archive_unstable_finalizedHeight.md)
14-
- [archive_unstable_genesisHash](api/archive_unstable_genesisHash.md)
15-
- [archive_unstable_hashByHeight](api/archive_unstable_hashByHeight.md)
16-
- [archive_unstable_header](api/archive_unstable_header.md)
17-
- [archive_unstable_storage](api/archive_unstable_storage.md)
11+
- [archive_v1_body](api/archive_v1_body.md)
12+
- [archive_v1_call](api/archive_v1_call.md)
13+
- [archive_v1_finalizedHeight](api/archive_v1_finalizedHeight.md)
14+
- [archive_v1_genesisHash](api/archive_v1_genesisHash.md)
15+
- [archive_v1_hashByHeight](api/archive_v1_hashByHeight.md)
16+
- [archive_v1_header](api/archive_v1_header.md)
17+
- [archive_v1_storage](api/archive_v1_storage.md)
1818
- [chainHead](api/chainHead.md)
1919
- [chainHead_v1_body](api/chainHead_v1_body.md)
2020
- [chainHead_v1_call](api/chainHead_v1_call.md)

src/api/archive.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ These functions are typically expensive for a JSON-RPC server, because they like
88

99
# Usage
1010

11-
The JSON-RPC server exposes a finalized block height, which can be retrieved by calling `archive_unstable_finalizedHeight`.
11+
The JSON-RPC server exposes a finalized block height, which can be retrieved by calling `archive_v1_finalizedHeight`.
1212

13-
Call `archive_unstable_hashByHeight` in order to obtain the hash of a block by its height.
13+
Call `archive_v1_hashByHeight` in order to obtain the hash of a block by its height.
1414

15-
If the height passed to `archive_unstable_hashByHeight` is inferior or equal to the value returned by `archive_unstable_finalizedHeight`, then it is always guaranteed that there is exactly one block with this hash.
16-
The JSON-RPC client can then call `archive_unstable_header`, `archive_unstable_body`, `archive_unstable_storage`, and `archive_unstable_call` in order to obtain details about the block with this hash. It is always guaranteed to return a value.
15+
If the height passed to `archive_v1_hashByHeight` is inferior or equal to the value returned by `archive_v1_finalizedHeight`, then it is always guaranteed that there is exactly one block with this hash.
16+
The JSON-RPC client can then call `archive_v1_header`, `archive_v1_body`, `archive_v1_storage`, and `archive_v1_call` in order to obtain details about the block with this hash. It is always guaranteed to return a value.
1717

18-
If the height passed to `archive_unstable_hashByHeight` is strictly superior to the value returned by `archive_unstable_finalizedHeight`, then `archive_unstable_hashByHeight` might return zero, one, or more blocks. Furthermore, the list of blocks being returned can change at any point. It is also possible to call `archive_unstable_header`, `archive_unstable_body`, `archive_unstable_storage`, and `archive_unstable_call` on these blocks, but these functions might return `null` even if their hash was previously returned by `archive_unstable_hashByHeight`.
18+
If the height passed to `archive_v1_hashByHeight` is strictly superior to the value returned by `archive_v1_finalizedHeight`, then `archive_v1_hashByHeight` might return zero, one, or more blocks. Furthermore, the list of blocks being returned can change at any point. It is also possible to call `archive_v1_header`, `archive_v1_body`, `archive_v1_storage`, and `archive_v1_call` on these blocks, but these functions might return `null` even if their hash was previously returned by `archive_v1_hashByHeight`.

src/api/archive_unstable_body.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/api/archive_unstable_header.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/api/archive_v1_body.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# archive_v1_body
2+
3+
**Parameters**:
4+
5+
- `hash`: String containing a hexadecimal-encoded hash of the header of the block whose body will be retrieved.
6+
7+
**Return value**: If a block with that hash is found, an array of strings containing the hexadecimal-encoded SCALE-codec-encoded transactions in that block. If no block with that hash is found, `null`.
8+
9+
If the block was previously returned by `archive_v1_hashByHeight` at a height inferior or equal to the current finalized block height (as indicated by `archive_v1_finalizedHeight`), then calling this method multiple times is guaranteed to always return non-null and always the same result.
10+
11+
If the block was previously returned by `archive_v1_hashByHeight` at a height strictly superior to the current finalized block height (as indicated by `archive_v1_finalizedHeight`), then the block might "disappear" and calling this function might return `null` at any point.

src/api/archive_unstable_call.md renamed to src/api/archive_v1_call.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# archive_unstable_call
1+
# archive_v1_call
22

33
**Parameters**:
44

@@ -16,7 +16,7 @@ The JSON-RPC server must invoke the entry point of the runtime of the given bloc
1616

1717
**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.
1818

19-
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).
19+
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_v1_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).
2020

2121
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.
2222

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# archive_unstable_finalizedHeight
1+
# archive_v1_finalizedHeight
22

33
**Parameters**: *none*
44

55
**Return value**: An integer height of the current finalized block of the chain.
66

77
The value returned by this function must only ever increase over time. In other words, if calling this function returns `N`, then calling it again later must return a value superior or equal to `N`.
88

9-
When implemented on a load balancer, keep in mind that the other functions of the `archive` namespace must always return the same value when the block's height is inferior or equal to the finalized block height indicated by this function. One possible implementation strategy is for this function to call `archive_unstable_finalizedHeight` on every node being load balanced and return the smallest value.
9+
When implemented on a load balancer, keep in mind that the other functions of the `archive` namespace must always return the same value when the block's height is inferior or equal to the finalized block height indicated by this function. One possible implementation strategy is for this function to call `archive_v1_finalizedHeight` on every node being load balanced and return the smallest value.
1010

1111
This function is expected to be called rarely by the JSON-RPC client. This function exists in order to give an indication of which blocks are accessible, and not for JSON-RPC clients to follow the finalized block. The `archive` namespace isn't meant to follow the head of the chain, and `chainHead` should be used instead in that situation.

src/api/archive_unstable_genesisHash.md renamed to src/api/archive_v1_genesisHash.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# archive_unstable_genesisHash
1+
# archive_v1_genesisHash
22

33
**Parameters**: *none*
44

src/api/archive_unstable_hashByHeight.md renamed to src/api/archive_v1_hashByHeight.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# archive_unstable_hashByHeight
1+
# archive_v1_hashByHeight
22

33
**Parameters**:
44

0 commit comments

Comments
 (0)