Uh oh!
There was an error while loading. Please reload this page.
Separate block confirmations - #501
Conversation
9e45e6a to
386000bCompare| account: AccountId, | ||
| amount: Amount, | ||
| shard: &ShardIdentifier, | ||
| calls: &mut Vec<OpaqueCall>, |
There was a problem hiding this comment.
Removed this input parameter, as there will never(!) be a new OpaqueCall introduced during Stf::execute of a shielding extrsinic. (New OpaqueCall is only issued during execute when calling "unshield")
There was a problem hiding this comment.
Thanks for clarifying this
Uh oh!
There was an error while loading. Please reload this page.
| sp-utils = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } | ||
| sp-version = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } | ||
| sp-application-crypto = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } | ||
| #beefy-merkle-tree = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master", features = "keccak" } |
There was a problem hiding this comment.
That's the ugly part here: substrate actually has a no-std compatible merkle tree primitives crate: https://github.com/paritytech/substrate/tree/master/frame/beefy-mmr/primitives
However, this was introduced on 23rd of September. We are not yet on this substrate commit. Can you agree with this temporary solution and to remove it once we are on this commit? If yes, I'll create an appropriate issue ofc.
There was a problem hiding this comment.
If it's well documented and even has a corresponding issue, that's totally fine for me 👍
| @@ -0,0 +1,229 @@ | |||
| // This file is part of Substrate. | |||
There was a problem hiding this comment.
This file was copy pasted from https://github.com/paritytech/substrate/blob/master/frame/beefy-mmr/primitives/src/lib.rs. Can be removed once we are above commit paritytech/substrate@65ac6f3
f1773ad to
5e49a19Compare| let xt_block = [TEEREX_MODULE, BLOCK_CONFIRMED]; | ||
| let opaque_call = | ||
| OpaqueCall::from_tuple(&(xt_block, shard, block_hash, state_hash_new.encode())); | ||
| let opaque_call = proposed_sidechain_block_extrinsic(shard, block_hash); |
There was a problem hiding this comment.
so we now use the sidechain block hash instead of the state hash for this extrinsic?
There was a problem hiding this comment.
Not exactly. State hash has been removed from the extrinsic as it didn't have any use case at all (#457)
| /// Creates a proposed_sidechain_block extrinsic for a given shard id and sidechain block hash. | ||
| fn proposed_sidechain_block_extrinsic(shard_id: ShardIdentifier, block_hash: H256) -> OpaqueCall { | ||
| OpaqueCall::from_tuple(&([TEEREX_MODULE, PROPOSED_SIDECHAIN_BLOCK], shard_id, block_hash)) | ||
| } |
There was a problem hiding this comment.
Also here, I'd prefer the create_ in front. In a future refactoring, we could put these into the extrinsics factory component or something similar?
There was a problem hiding this comment.
Already changed. :) Yes, definitely - but I think the whole lib.rs (just like in PR #500 but also for parentchain syncing) should be refactored (but that's your call).. I didn't want to start something that will be changed in the future anyway. If you have a place they belong to already, I'll gladly move them.
| fn empty_extrinsic_vec_gives_zero_merkle_root() { | ||
| // given | ||
| let block_hash = H256::from([1; 32]); | ||
| let extrinsics = Vec::new(); | ||
| let expected_call = | ||
| ([TEEREX_MODULE, PROCESSED_PARENTCHAIN_BLOCK], block_hash, H256::default()).encode(); | ||
| // when | ||
| let call = crate::processed_parentchain_block_extrinsic(block_hash, extrinsics); | ||
| // then | ||
| assert_eq!(call.0, expected_call); | ||
| } | ||
| fn some_extrinsics_vec_give_non_zero_merkle_root() { | ||
| // given | ||
| let block_hash = H256::from([1; 32]); | ||
| let extrinsics = vec![H256::from([4; 32]), H256::from([9; 32])]; | ||
| let zero_root_call = | ||
| ([TEEREX_MODULE, PROCESSED_PARENTCHAIN_BLOCK], block_hash, H256::default()).encode(); | ||
| // when | ||
| let call = crate::processed_parentchain_block_extrinsic(block_hash, extrinsics); | ||
| // then | ||
| assert_ne!(call.0, zero_root_call); | ||
| } |
There was a problem hiding this comment.
Always nice to have tests for the changes you make 🥳
| fn hash_of<T: Encode>(xt: T) -> H256 { | ||
| blake2_256(&xt.encode()).into() |
There was a problem hiding this comment.
This is a function that we have duplicated multiple times I believe. We should at some point put it in a primitives crate where it can be properly shared.
There was a problem hiding this comment.
Aye.. But I didn't want to touch too much code, in fear of the rebase conflicts 😨
There was a problem hiding this comment.
I think we should simply implement hash on the extrinsic in the api-client. 😄
murerfel
left a comment
There was a problem hiding this comment.
LGTM - and if the checks pass, it should be fine
| account: AccountId, | ||
| amount: Amount, | ||
| shard: &ShardIdentifier, | ||
| calls: &mut Vec<OpaqueCall>, |
| sp-utils = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } | ||
| sp-version = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } | ||
| sp-application-crypto = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" } | ||
| #beefy-merkle-tree = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master", features = "keccak" } |
| if let Err(e) = validator.submit_simple_header( | ||
| validator.num_relays(), | ||
| signed_block.block.header().clone(), | ||
| block.header().clone(), |
| fn hash_of<T: Encode>(xt: T) -> H256 { | ||
| blake2_256(&xt.encode()).into() |
There was a problem hiding this comment.
I think we should simply implement hash on the extrinsic in the api-client. 😄
Seems to work quite well: For every parentchain block we get 20 sidechain block events.

Introduces the following changes:
closes#457