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

Support and include MMR in blockheader #344

Closed
hackfisher opened this issue Mar 13, 2020 · 4 comments · Fixed by darwinia-network/substrate#1 or #358
Closed

Support and include MMR in blockheader #344

hackfisher opened this issue Mar 13, 2020 · 4 comments · Fixed by darwinia-network/substrate#1 or #358
Assignees
Labels
U-Question [Uncategorized] Further information/discussion is requested

Comments

@hackfisher
Copy link
Contributor

For easier darwinia relay support

@hackfisher hackfisher added the U-Question [Uncategorized] Further information/discussion is requested label Mar 13, 2020
@aurexav
Copy link
Member

aurexav commented Mar 13, 2020

@hackfisher
Copy link
Contributor Author

Transfer to https://github.com/darwinia-network/research?

Actually the research is almost done? The works left is about the engineering stuffs related to Substrate Runtime primitives, constructing block and MMR calculating.

Here are some code links:

Header Struct:
https://github.com/paritytech/substrate/blob/v2.0.0-alpha.3/primitives/runtime/src/generic/header.rs#L39

Block Builder:
https://github.com/paritytech/substrate/blob/v2.0.0-alpha.3/client/block-builder/src/lib.rs#L205

MMR struct and append:

https://github.com/darwinia-network/darwinia/blob/icefrog/core/merkle-mountain-range/src/mmr.rs#L44

It will be great if we can do it in Crab Network.

@hackfisher hackfisher added this to the Darwinia Crab Network milestone Mar 14, 2020
@hackfisher
Copy link
Contributor Author

We could implement it in a separate branch while waiting for the substrate stable release.

@hackfisher
Copy link
Contributor Author

There is a digest data in Header struct, could we make use of it for easy extend of Substrate code, if it works, then we might not need to introduce modification to Substrate runtime primitives too much.

https://github.com/paritytech/substrate/blob/v2.0.0-alpha.3/primitives/runtime/src/generic/header.rs#L52

pub struct Header<Number: Copy + Into<U256> + TryFrom<U256>, Hash: HashT> {
	/// The parent hash.
	pub parent_hash: Hash::Output,
	/// The block number.
	#[cfg_attr(feature = "std", serde(
		serialize_with = "serialize_number",
		deserialize_with = "deserialize_number"))]
	pub number: Number,
	/// The state trie merkle root
	pub state_root: Hash::Output,
	/// The merkle root of the extrinsics.
	pub extrinsics_root: Hash::Output,
	/// A chain-specific digest of data useful for light clients or referencing auxiliary data.
	pub digest: Digest<Hash::Output>,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
U-Question [Uncategorized] Further information/discussion is requested
Projects
None yet
2 participants