Skip to content

Support paginationStartKey parameter in the archive_v1_storage JSON-RPC API #10185

@sinzii

Description

@sinzii

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Request

Per the latest archive_v1_storage specification, the paginationStartKey parameter enables specifying a starting key for fetching storage items, which facilitates paginated retrieval.

It appears that the current implementation of archive_v1_storage does not yet support this parameter. Do we have plans to add support for it to ensure the API aligns with the specification?

fn archive_v1_storage(
&self,
pending: PendingSubscriptionSink,
hash: Block::Hash,
items: Vec<StorageQuery<String>>,
child_trie: Option<String>,
) {
let mut storage_client =
StorageSubscriptionClient::<Client, Block, BE>::new(self.client.clone());
let fut = async move {
let Ok(mut sink) = pending.accept().await.map(Subscription::from) else { return };
let items = match items
.into_iter()
.map(|query| {
let key = StorageKey(parse_hex_param(query.key)?);
Ok(StorageQuery { key, query_type: query.query_type })
})
.collect::<Result<Vec<_>, ArchiveError>>()
{
Ok(items) => items,
Err(error) => {
let _ = sink.send(&ArchiveStorageEvent::err(error.to_string()));
return
},
};
let child_trie = child_trie.map(|child_trie| parse_hex_param(child_trie)).transpose();
let child_trie = match child_trie {
Ok(child_trie) => child_trie.map(ChildInfo::new_default_from_vec),
Err(error) => {
let _ = sink.send(&ArchiveStorageEvent::err(error.to_string()));
return
},
};
let (tx, mut rx) = tokio::sync::mpsc::channel(STORAGE_QUERY_BUF);
let storage_fut = storage_client.generate_events(hash, items, child_trie, tx);
// We don't care about the return value of this join:
// - process_events might encounter an error (if the client disconnected)
// - storage_fut might encounter an error while processing a trie queries and
// the error is propagated via the sink.
let _ = futures::future::join(storage_fut, process_storage_events(&mut rx, &mut sink))
.await;
};
self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed());
}

Metadata

Metadata

Assignees

Labels

C2-good-first-issueA task for a first time contributor to become familiar with the Polkadot-SDK.I5-enhancementAn additional feature request.

Type

No type

Projects

Status

backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions