BlockId removal: refactor: StorageProvider (#12510)

* BlockId removal: refactor: StorageProvider

It changes the arguments of `Backend::StorageProvider` trait from:
block: `BlockId<Block>` to: hash: `&Block::Hash`

This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292)

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <git@kchr.de>

* Update client/api/src/backend.rs

Co-authored-by: Dmitrii Markin <dmitry@markin.tech>

* GrandpaBlockImport::current_set_id reworked

* ExportStateCmd reworked

* trigger CI job

* trigger CI job

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Dmitrii Markin <dmitry@markin.tech>
This commit is contained in:
Michal Kucharczyk
2022-10-18 14:52:04 +02:00
committed by GitHub
parent 2f341fcf15
commit b16135f602
12 changed files with 112 additions and 120 deletions
@@ -1602,12 +1602,14 @@ fn storage_keys_iter_prefix_and_start_key_works() {
.add_extra_child_storage(&child_info, b"third".to_vec(), vec![0u8; 32])
.build();
let block_hash = client.info().best_hash;
let child_root = b":child_storage:default:child".to_vec();
let prefix = StorageKey(array_bytes::hex2bytes_unchecked("3a"));
let child_prefix = StorageKey(b"sec".to_vec());
let res: Vec<_> = client
.storage_keys_iter(&BlockId::Number(0), Some(&prefix), None)
.storage_keys_iter(&block_hash, Some(&prefix), None)
.unwrap()
.map(|x| x.0)
.collect();
@@ -1622,7 +1624,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
let res: Vec<_> = client
.storage_keys_iter(
&BlockId::Number(0),
&block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a636f6465"))),
)
@@ -1633,7 +1635,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
let res: Vec<_> = client
.storage_keys_iter(
&BlockId::Number(0),
&block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a686561707061676573"))),
)
@@ -1643,7 +1645,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
assert_eq!(res, Vec::<Vec<u8>>::new());
let res: Vec<_> = client
.child_storage_keys_iter(&BlockId::Number(0), child_info.clone(), Some(&child_prefix), None)
.child_storage_keys_iter(&block_hash, child_info.clone(), Some(&child_prefix), None)
.unwrap()
.map(|x| x.0)
.collect();
@@ -1651,7 +1653,7 @@ fn storage_keys_iter_prefix_and_start_key_works() {
let res: Vec<_> = client
.child_storage_keys_iter(
&BlockId::Number(0),
&block_hash,
child_info,
None,
Some(&StorageKey(b"second".to_vec())),
@@ -1666,10 +1668,12 @@ fn storage_keys_iter_prefix_and_start_key_works() {
fn storage_keys_iter_works() {
let client = substrate_test_runtime_client::new();
let block_hash = client.info().best_hash;
let prefix = StorageKey(array_bytes::hex2bytes_unchecked(""));
let res: Vec<_> = client
.storage_keys_iter(&BlockId::Number(0), Some(&prefix), None)
.storage_keys_iter(&block_hash, Some(&prefix), None)
.unwrap()
.take(9)
.map(|x| array_bytes::bytes2hex("", &x.0))
@@ -1691,7 +1695,7 @@ fn storage_keys_iter_works() {
let res: Vec<_> = client
.storage_keys_iter(
&BlockId::Number(0),
&block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked("3a636f6465"))),
)
@@ -1714,7 +1718,7 @@ fn storage_keys_iter_works() {
let res: Vec<_> = client
.storage_keys_iter(
&BlockId::Number(0),
&block_hash,
Some(&prefix),
Some(&StorageKey(array_bytes::hex2bytes_unchecked(
"7d5007603a7f5dd729d51d93cf695d6465789443bb967c0d1fe270e388c96eaa",