Skip to content

Commit

Permalink
beefy pallet - updates
Browse files Browse the repository at this point in the history
- impl OwnedBridgeModule
- define LOG_TARGET
- fix clippy warnings
  • Loading branch information
serban300 committed Sep 7, 2022
1 parent 1af3985 commit 3f5f6b5
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 169 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions modules/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", branch = "
pallet-mmr = { git = "https://github.com/paritytech/substrate", branch = "master" }
rand = "0.8"
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
bp-test-utils = { path = "../../primitives/test-utils" }

[features]
default = ["std"]
Expand Down
10 changes: 2 additions & 8 deletions modules/beefy/src/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,7 @@ mod tests {
&BridgedBeefyValidatorSet::<TestRuntime, ()>::new(validator_ids(0, 8), 0).unwrap(),
&sign_commitment(
Commitment {
payload: BeefyPayload::new(
MMR_ROOT_PAYLOAD_ID,
BeefyMmrHash::from([42u8; 32]).encode(),
),
payload: BeefyPayload::new(MMR_ROOT_PAYLOAD_ID, [42u8; 32].encode()),
block_number: 20,
validator_set_id: 0,
},
Expand All @@ -268,10 +265,7 @@ mod tests {

assert_eq!(
artifacts,
CommitmentVerificationArtifacts {
finalized_block_number: 20,
mmr_root: BeefyMmrHash::from([42u8; 32]),
}
CommitmentVerificationArtifacts { finalized_block_number: 20, mmr_root: [42u8; 32] }
);
}
}
6 changes: 3 additions & 3 deletions modules/beefy/src/leaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where
);
// technically it is not an error, but we'd like to reduce tx size on real chains
ensure!(
!mmr_leaf.next_validators().is_some() || is_updating_validator_set,
mmr_leaf.next_validators().is_none() || is_updating_validator_set,
Error::<T, I>::RedundantNextValidatorsProvided,
);
ensure!(
Expand Down Expand Up @@ -114,7 +114,7 @@ where
.map(BridgedBeefyValidatorIdToMerkleLeaf::<T, I>::convert)
.collect::<Vec<_>>();
let next_validator_addresses_root: BeefyMmrHash =
beefy_merkle_root::<BridgedBeefyMmrHasher<T, I>, _, _>(next_validator_addresses).into();
beefy_merkle_root::<BridgedBeefyMmrHasher<T, I>, _, _>(next_validator_addresses);
ensure!(
next_validator_addresses_root == raw_mmr_leaf.beefy_next_authority_set.root,
Error::<T, I>::InvalidNextValidatorSetRoot
Expand Down Expand Up @@ -283,7 +283,7 @@ mod tests {
.custom_header()
.customize_leaf(|leaf| {
let mut raw_leaf = BridgedRawMmrLeaf::decode(&mut &leaf.leaf()[..]).unwrap();
raw_leaf.parent_number_and_hash.0 = raw_leaf.parent_number_and_hash.0 + 1;
raw_leaf.parent_number_and_hash.0 += 1;
leaf.set_leaf(raw_leaf.encode())
})
.finalize()
Expand Down
Loading

0 comments on commit 3f5f6b5

Please sign in to comment.