introduce a method for fetching relay chain header to RelayChainInterface#2794
introduce a method for fetching relay chain header to RelayChainInterface#2794bkchr merged 3 commits intoparitytech:masterfrom polytope-labs:seun/relay-chain-interface
RelayChainInterface#2794Conversation
|
Yeah my use case requires block numbers |
| async fn best_block_hash(&self) -> RelayChainResult<PHash>; | ||
|
|
||
| /// Fetch the block header of a given height | ||
| async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>>; |
There was a problem hiding this comment.
Please use PHash. No new BlockId in public interfaces anymore.
There was a problem hiding this comment.
But i specifically need to query using BlockNumber, any reason for this?
No new BlockId in public interfaces anymore
There was a problem hiding this comment.
Block numbers should only be used in places where there is no other way around them. Block numbers are not ambiguous. Some interfaces (like RPC/CLI) still require block numbers, but most "internal code" can be rewritten in a way to use hashes. E.g. get the header of block X and then go back using parent_hash().
There was a problem hiding this comment.
But i specifically need to query using BlockNumber, any reason for this?
The use case here is on-chain code which wishes to read the relay chain, they signal a request given a specific relay chain height (parachains don't have access to the relay chain blockhashes). So hence the BlockId here.
Doesn't seem like there's any alternatives here
There was a problem hiding this comment.
And how does the parachain validates the relay chain headers?
There was a problem hiding this comment.
It doesn't need the header, it has the state_root from PersistedValidationData
There was a problem hiding this comment.
The use case here is on-chain code which wishes to read the relay chain, they signal a request given a specific relay chain height (parachains don't have access to the relay chain blockhashes).
You say it signals which relay chain header it wants to read. So you are just wanting to get the header to get the storage root?
There was a problem hiding this comment.
Okay, when we got: https://github.com/paritytech/cumulus/issues/303
This can be changed.
| async fn best_block_hash(&self) -> RelayChainResult<PHash>; | ||
|
|
||
| /// Fetch the block header of a given height | ||
| async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>>; |
There was a problem hiding this comment.
Okay, when we got: https://github.com/paritytech/cumulus/issues/303
This can be changed.
|
This shouldn't have been merged as-is - the interface was changed to |
|
By "opaque error" you mean that it is a string error? |
|
Will do a follow up |
|
follow up: #2830 |
This is particularly useful for fetching arbitrary relay chain headers within inherents.