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

Set up type definitions for the sync state #62

Merged
merged 6 commits into from
Oct 15, 2020
Merged

Conversation

expenses
Copy link
Contributor

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

@expenses expenses requested a review from tomaka October 13, 2020 10:06
use super::structs::StorageData;
use crate::header::{BabeAuthority, BabeNextConfig, GrandpaAuthority};
use parity_scale_codec::*;
use primitive_types::H256;
Copy link
Contributor

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

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(
Debug, Copy, Clone, PartialEq, Eq, parity_scale_codec::Encode, parity_scale_codec::Decode,
)]
pub struct GrandpaAuthority {
Copy link
Contributor

@tomaka tomaka Oct 14, 2020

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.

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(
Debug, Copy, Clone, PartialEq, Eq, parity_scale_codec::Encode, parity_scale_codec::Decode,
)]
pub struct BabeAuthority {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

#[derive(Debug, Decode, Encode)]
pub(super) struct EpochChanges {
inner: ForkTree<PersistedEpochHeader>,
epochs: std::collections::BTreeMap<(H256, u32), PersistedEpoch>,
Copy link
Contributor

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.

@@ -0,0 +1,115 @@
use super::structs::StorageData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license header

@expenses expenses requested a review from tomaka October 14, 2020 12:28
Copy link
Contributor

@tomaka tomaka left a 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?

@expenses
Copy link
Contributor Author

I think it'd be better to wait until paritytech/substrate#7225 gets merged.

Comment on lines 1 to 15
// 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/>.
Copy link
Contributor

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!

Copy link
Contributor Author

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 😉

@expenses expenses requested a review from tomaka October 14, 2020 14:19
@expenses
Copy link
Contributor Author

This can be merged now.

@tomaka tomaka merged commit 93e7862 into main Oct 15, 2020
@tomaka tomaka deleted the ashley-sync-state branch October 15, 2020 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants