mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
BlockId removal: runtime-api refactor (#13255)
* BlockId removal: refactor of runtime API It changes the arguments of: - `ApiExt` methods: `has_api`, `has_api_with`, `api_version` - `CallApiAt` method: `runtime_version_at` from: `BlockId<Block>` to: `Block::Hash` It also changes the first argument of all generated runtime API calls from: `BlockId<Block>` to: `Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * BlockId removal: refactor of runtime API - tests - tests adjusted to new runtime API, - some tests migrated from block number to block hash * benchmarking-cli: BlockId(0) migrated to info().genesis_hash `runtime_api.call()` now requires the block hash instead of BlockId::Number. To access the genesis hash widely used in benchmarking engine the Client was constrained to satisfy `sp_blockchain::HeaderBackend<Block>` trait which provides `info().genesis_hash`. * trivial: api.call(BlockId) -> api.call(Hash) - Migrated all `runtime_api.calls` to use Hash - Noteworthy (?): -- `validate_transaction_blocking` in transaction pool, * CallApiAtParams::at changed to Block::Hash * missed doc updated * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * ".git/.scripts/commands/fmt/fmt.sh" * BlockId removal: Benchmark::consumed_weight Little refactor around `Benchmark::consumed_weight`: `BlockId` removed. * at_hash renamed * wrong merge fixed * beefy worker: merged with master * beefy: tests: missing block problem fixed * Apply review suggestion * fix --------- Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
ac13aaeb2f
commit
7a10154188
+1
-1
@@ -12,7 +12,7 @@ struct MockApi;
|
||||
sp_api::mock_impl_runtime_apis! {
|
||||
impl Api<Block> for MockApi {
|
||||
#[advanced]
|
||||
fn test(&self, _: BlockId<Block>) -> Result<(), ApiError> {
|
||||
fn test(&self, _: &Hash) -> Result<(), ApiError> {
|
||||
Ok(().into())
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
error: `BlockId` needs to be taken by reference and not by value!
|
||||
--> tests/ui/mock_advanced_block_id_by_value.rs:12:1
|
||||
error: `Hash` needs to be taken by value and not by reference!
|
||||
--> tests/ui/mock_advanced_hash_by_reference.rs:12:1
|
||||
|
|
||||
12 | / sp_api::mock_impl_runtime_apis! {
|
||||
13 | | impl Api<Block> for MockApi {
|
||||
14 | | #[advanced]
|
||||
15 | | fn test(&self, _: BlockId<Block>) -> Result<(), ApiError> {
|
||||
15 | | fn test(&self, _: &Hash) -> Result<(), ApiError> {
|
||||
... |
|
||||
18 | | }
|
||||
19 | | }
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
error: If using the `advanced` attribute, it is required that the function takes at least one argument, the `BlockId`.
|
||||
--> tests/ui/mock_advanced_missing_blockid.rs:15:3
|
||||
error: If using the `advanced` attribute, it is required that the function takes at least one argument, the `Hash`.
|
||||
--> tests/ui/mock_advanced_missing_hash.rs:15:3
|
||||
|
|
||||
15 | fn test(&self) -> Result<(), ApiError> {
|
||||
| ^^
|
||||
Reference in New Issue
Block a user