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

Commit

Permalink
Derive scale_info::TypeInfo for types used in polkadot (#218)
Browse files Browse the repository at this point in the history
* Add scale-info TypeInfo derives

* Update scale-info

* Add crates.io patches

* Use substrate aj-metadata-vnext branch

* Revert master branch substrate deps

* Add scale-info to beefy-pallet

* scale-info v0.9.0

* Remove github dependencies and patches

* More TypeInfo derives

* Update scale-info to 0.10.0

* Add missing scale-info dependency

* Add missing TypeInfo derive

* Hide TypeInfo under a feature.

Co-authored-by: Tomasz Drwięga <[email protected]>
  • Loading branch information
ascjones and tomusdrw authored Jul 30, 2021
1 parent af8bb2e commit b0ac09f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ thiserror = "1.0"
wasm-timer = "0.2.5"

codec = { version = "2.0.0", package = "parity-scale-codec", features = ["derive"] }
prometheus = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master"}
prometheus = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master" }

sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
1 change: 1 addition & 0 deletions frame/beefy-mmr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ hex = { version = "0.4", optional = true }
codec = { version = "2.0.0", package = "parity-scale-codec", default-features = false, features = ["derive"] }
libsecp256k1 = { version = "0.6.0", default-features = false }
log = { version = "0.4.13", default-features = false }
scale-info = { version = "0.10.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.126", optional = true }

frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down
2 changes: 2 additions & 0 deletions frame/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
codec = { version = "2.0.0", package = "parity-scale-codec", default-features = false, features = ["derive"] }
scale-info = { version = "0.10.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.126", optional = true }

frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand All @@ -28,6 +29,7 @@ sp-staking = { git = "https://github.com/paritytech/substrate.git", branch = "ma
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"serde",
"beefy-primitives/std",
"frame-support/std",
Expand Down
1 change: 1 addition & 0 deletions primitives/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
codec = { version = "2.0.0", package = "parity-scale-codec", default-features = false, features = ["derive"] }
scale-info = { version = "0.10.0", default-features = false, features = ["derive"], optional = true }

sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down
3 changes: 3 additions & 0 deletions primitives/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub type ValidatorSetId = u64;

/// A set of BEEFY authorities, a.k.a. validators.
#[derive(Decode, Encode, Debug, PartialEq, Clone)]
#[cfg_attr(feature = "scale-info", derive(scale_info::TypeInfo))]
pub struct ValidatorSet<AuthorityId> {
/// Public keys of the validator set elements
pub validators: Vec<AuthorityId>,
Expand All @@ -104,6 +105,7 @@ pub type MmrRootHash = H256;

/// A consensus log item for BEEFY.
#[derive(Decode, Encode)]
#[cfg_attr(feature = "scale-info", derive(scale_info::TypeInfo))]
pub enum ConsensusLog<AuthorityId: Codec> {
/// The authorities have changed.
#[codec(index = 1)]
Expand All @@ -121,6 +123,7 @@ pub enum ConsensusLog<AuthorityId: Codec> {
/// A vote message is a direct vote created by a BEEFY node on every voting round
/// and is gossiped to its peers.
#[derive(Debug, Decode, Encode)]
#[cfg_attr(feature = "scale-info", derive(scale_info::TypeInfo))]
pub struct VoteMessage<Hash, Number, Id, Signature> {
/// Commit to information extracted from a finalized block
pub commitment: Commitment<Number, Hash>,
Expand Down
1 change: 1 addition & 0 deletions primitives/beefy/src/mmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl MmrLeafVersion {

/// Details of the next BEEFY authority set.
#[derive(Debug, Default, PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "scale-info", derive(scale_info::TypeInfo))]
pub struct BeefyNextAuthoritySet<MerkleRoot> {
/// Id of the next set.
///
Expand Down

0 comments on commit b0ac09f

Please sign in to comment.