Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define block hash provider and default impl using frame_system #4080

Merged
merged 3 commits into from
Apr 12, 2024

Conversation

vedhavyas
Copy link
Contributor

@vedhavyas vedhavyas commented Apr 11, 2024

This PR introduces BlockHashProvider into pallet_mmr::Config
This type is used to get block_hash for a given block_number rather than directly using frame_system::Pallet::block_hash

The DefaultBlockHashProvider uses frame_system::Pallet::block_hash to get the block_hash

Closes: #4062

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5881092

Copy link
Contributor

@serban300 serban300 left a comment

Choose a reason for hiding this comment

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

The PR makes sense for MMR. I was also wondering if in order to make it more generic it would make sense to change frame_system::Config::BlockHashCount to a method or something more generic. Not sure. But we could explore this in a separate issue. And related to this I was curious how your BlockHashProvider implementation looks like. Are you keeping a separate item in the storage with more block_num -> block_hash items then the frame_system ? And how do you decide when to prune that ?

substrate/frame/merkle-mountain-range/src/lib.rs Outdated Show resolved Hide resolved
@vedhavyas
Copy link
Contributor Author

vedhavyas commented Apr 11, 2024

I was also wondering if in order to make it more generic it would make sense to change frame_system::Config::BlockHashCount to a method or something more generic.

I'm not quiet sure how this would work for chains that do not have quick finality. Subspace for example, Runtime would not know at which point finality comes so our BlockHashCount method should ideally be able to Host function or something else for this. This seems to introduce more tricky situations on the first thought but we will need to think more on this.

But we could explore this in a separate issue.

That is fair. Thanks!

And related to this I was curious how your BlockHashProvider implementation looks like. Are you keeping a separate item in the storage with more block_num -> block_hash items then the frame_system ? And how do you decide when to prune that ?

At the moment, we have not decided on the approach of how to fetch yet but we have some options.

  • Our domains, enshrined rollups, would need to know consensus hash so we have storage for these hashes and we are planning to use these but there are potential concerns that came up with this usage
  • Other option is to use a Host function to fetch the canonical hash using the block_number since, I believe, we will have access to those until the finality occurs.

Overall, this PR should allow us to impl BlockHashProvider depending on which approach we take

@vedhavyas
Copy link
Contributor Author

@serban300 seems like check is failing, IIUC, is unrelated to this PR. Is this expected ?

@serban300 serban300 added R0-silent Changes should not be mentioned in any release notes T15-bridges This PR/Issue is related to bridges. labels Apr 11, 2024
@serban300
Copy link
Contributor

@serban300 seems like check is failing, IIUC, is unrelated to this PR. Is this expected ?

Yes, the failing checks are unrelated to the PR so far

@vedhavyas
Copy link
Contributor Author

vedhavyas commented Apr 12, 2024

@acatangiu @serban300 I'm not sure why the the required test failed. Seems like the change is not related to it. I would really appreciate your help on this. Thank you!

@serban300
Copy link
Contributor

test-linux-oldkernel-stable 1/3 has been having issues lately. I'll retry it

@acatangiu acatangiu added this pull request to the merge queue Apr 12, 2024
@serban300 serban300 removed this pull request from the merge queue due to a manual request Apr 12, 2024
@serban300 serban300 added this pull request to the merge queue Apr 12, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Apr 12, 2024
@bkchr bkchr added this pull request to the merge queue Apr 12, 2024
Merged via the queue into paritytech:master with commit 5b513cc Apr 12, 2024
138 of 143 checks passed
@vedhavyas vedhavyas deleted the mmr_block_hash_getter branch April 13, 2024 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes T15-bridges This PR/Issue is related to bridges.
Projects
None yet
5 participants