-
Notifications
You must be signed in to change notification settings - Fork 75
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
Set up type definitions for the sync state #62
Conversation
src/chain_spec/light_sync_state.rs
Outdated
use super::structs::StorageData; | ||
use crate::header::{BabeAuthority, BabeNextConfig, GrandpaAuthority}; | ||
use parity_scale_codec::*; | ||
use primitive_types::H256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use [u8; 32]
everywhere instead of H256
src/header/grandpa.rs
Outdated
#[derive(Debug, Copy, Clone, PartialEq, Eq)] | ||
#[derive( | ||
Debug, Copy, Clone, PartialEq, Eq, parity_scale_codec::Encode, parity_scale_codec::Decode, | ||
)] | ||
pub struct GrandpaAuthority { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to derive Encode
and Decode
.
Please copy-paste the definition of GrandpaAuthority
in light_sync_state.rs
if you need these traits.
src/header/babe.rs
Outdated
#[derive(Debug, Copy, Clone, PartialEq, Eq)] | ||
#[derive( | ||
Debug, Copy, Clone, PartialEq, Eq, parity_scale_codec::Encode, parity_scale_codec::Decode, | ||
)] | ||
pub struct BabeAuthority { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
src/chain_spec/light_sync_state.rs
Outdated
#[derive(Debug, Decode, Encode)] | ||
pub(super) struct EpochChanges { | ||
inner: ForkTree<PersistedEpochHeader>, | ||
epochs: std::collections::BTreeMap<(H256, u32), PersistedEpoch>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be alloc::collections::BTreeMap
, and imported on top of the file.
src/chain_spec/light_sync_state.rs
Outdated
@@ -0,0 +1,115 @@ | |||
use super::structs::StorageData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 That's entirely scoped to the chain_spec
module now.
Should I merge now? Or is it still work in progress?
I think it'd be better to wait until paritytech/substrate#7225 gets merged. |
src/chain_spec/light_sync_state.rs
Outdated
// Copyright 2017-2020 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate. | ||
|
||
// Substrate is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Substrate is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Substrate-lite has a different header. It is literally in every file!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the file I copied it from 😉
This can be merged now. |
This PR sets up all the type definitions needed to decode the sync states from paritytech/substrate#7225. This doesn't set up anything to load the sync state into the chain infomation yet. For testing, you can use this chain spec: https://github.com/paritytech/substrate/blob/a9b22d4e901c2633f92fefc6cbfbf1d3a9971ecc/bin/node/cli/res/flaming-fir.json