Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Make functionality to read relay state proof entries public #1135

Merged
merged 6 commits into from
Apr 11, 2022

Conversation

4meta5
Copy link
Contributor

@4meta5 4meta5 commented Apr 4, 2022

Follow up for #1083 which makes the functionality to read arbitrary entries in the relay state proof public. We need this to read the BABE randomness values from the proof.

Let me know if there is a better way to do this @bkchr

@@ -273,4 +277,18 @@ impl RelayChainStateProof {
)
.map_err(Error::UpgradeRestriction)
}

pub fn read_entry<T>(&self, key: &[u8], fallback: Option<T>) -> Result<T, Error>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not directly expose the functions to read the babe randomness? As we do for all the other values?

Copy link
Contributor Author

@4meta5 4meta5 Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we will need functions for every value we would like to get. This will be at least:

read_current_block_randomness
read_one_epoch_ago_randomness
read_two_epochs_ago_randomness
read_epoch_index

It is less code to write one read_entry<T> which is generic over the successful result value returned.

Why not directly expose the functions to read the babe randomness? As we do for all the other values?

This approach also requires adding a new function if we ever want to read a new value from the RelayChainStateProof and that comes with a release delay so it is not preferred.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get what you say, but currently it also requires that you add these values before on the client side :P

We can add this function, I don't really care, but then please add some docs :)

@4meta5
Copy link
Contributor Author

4meta5 commented Apr 7, 2022

@bkchr Any suggestions to get the CI green? It succeeded on the only commit which changed the code, but is now failing after added doc comments.

error[E0425]: cannot find function `with_transaction_unchecked` in module `frame_support::storage`
     --> /usr/local/cargo/git/checkouts/polkadot-4038f27d5e4ea2e8/21f06c3/runtime/parachains/src/paras_inherent/mod.rs:606:31
      |
  606 |         ) = frame_support::storage::with_transaction_unchecked(|| {
      |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `frame_support::storage`
  warning: ignoring -C extra-filename flag due to -o flag
  For more information about this error, try `rustc --explain E0425`.
  warning: `polkadot-runtime-parachains` (lib) generated 1 warning
  error: could not compile `polkadot-runtime-parachains` due to previous error; 1 warning emitted
  warning: build failed, waiting for other jobs to finish...
  error: build failed
warning: build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:
warning: `WASM_BUILD_WORKSPACE_HINT` env variable doesn't point to a directory that contains a `Cargo.lock`.

@bkchr
Copy link
Member

bkchr commented Apr 8, 2022

@4meta5 can you please merge master

@bkchr bkchr added A0-pleasereview B0-silent Changes should not be mentioned in any release notes labels Apr 11, 2022
@bkchr bkchr merged commit 17a3f30 into paritytech:master Apr 11, 2022
@4meta5 4meta5 deleted the amar-make-read-entry-public branch April 11, 2022 14:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
B0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants